Agent Access Control with Telegram & Airtable in n8n Automation

This n8n workflow automates secure access control by integrating Telegram and Airtable to check user permissions before running AI tools. It prevents unauthorized tool usage, saving time and ensuring compliance.
Telegram Trigger
Airtable
Agent
+11
Workflow Identifier: 1757
NODES in Use: Telegram Trigger, Airtable, Set, Agent, Code, Simple Memory, Telegram, OpenAI Chat Model, ToolCode, ToolCalculator, ToolWikipedia, ToolHttpRequest, ToolWorkflow, ExecuteWorkflowTrigger

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

Opening Problem Statement

Imagine you are Sarah, an operations manager at a company using multiple AI-powered tools to assist your team. Your team members access these tools via Telegram, but the problem is that not all employees should have access to every tool due to sensitive data and licensing limitations. Every day, Sarah spends hours manually verifying who can access which AI tool and constantly manages user permissions in different systems. Mistakes in this process cause unauthorized tool use, which wastes resources and risks exposing sensitive information.

This workflow solves Sarah’s problem specifically by automating agent access control for AI tools, ensuring each Telegram user can only utilize the tools they’re authorized to use, based on dynamic permissions stored in Airtable.

What This Automation Does

When this n8n workflow runs, it securely manages who can access specific AI utilities through Telegram commands, performing the following tasks:

  • Listens for messages sent directly by authorized Telegram users.
  • Fetches each user’s permissions (roles and allowed tools) from an Airtable database automatically.
  • Dynamically adjusts AI tools within the session, disabling unauthorized tools by overriding their functionality with a fixed “not authorized” message.
  • Routes user input to a customized AI personal assistant agent that works only within permitted tools and provides relevant responses.
  • Displays clear feedback to unauthorized users, advising them to contact supervisors.
  • Supports sub-agents for specialized tasks, like weather data retrieval, with the same permission controls.

This automation saves hours of manual user management daily and minimizes errors by leveraging dynamic permission checks directly within AI tool usage.

Prerequisites ⚙️

  • Telegram Bot with API access 📧 (to receive messages and reply)
  • Airtable with a configured Base and Table for user permissions and allowed tools 🔑
  • OpenAI API key for AI-powered conversational agents 🔐
  • n8n account with the capability to install Langchain and Airtable nodes ⏱️
  • Optional: Self-hosting approach to run n8n on your own servers (consider using Hostinger)

Step-by-Step Guide

1. Set up Telegram Trigger to receive user messages

Navigate to Nodes > Add Node and select Telegram Trigger. Configure it with your Telegram bot credential. Set the node to listen for “message” updates only. This node will capture messages sent directly to your Telegram bot.

After activation, messages sent to your bot will trigger this workflow.

Common Mistake: Forgetting to add your bot’s API credential or enabling required Telegram permissions.

2. Query user permissions from Airtable

Add an Airtable node named “Get user permissions” and connect it to the Telegram Trigger. Configure it to search by username using the formula =formula = '{{ $json.message.from.username }}'. Select fields for name, granted_roles, and allowed_tools so you know what each user can access.

The Airtable Base and Table need to be preconfigured with these fields for this lookup.

Expected Outcome: If the user is found, data flows downstream; if not, the workflow routes to handle unknown users.

3. Identify unknown users and reply

Use an If node configured with condition checking for empty Airtable results. If empty, route to a Telegram node that replies with a message like “Unknown user ‘username’. Please contact your supervisor.” This step ensures unauthorized users cannot proceed.

Common Mistake: Not setting the If node condition properly leads to errors or unintended behavior.

4. Format permissions info with a Set node

Add a Set node named “Set input” to extract and format name, granted_roles, and allowed_tools. This makes it easy for downstream nodes to use this data in their logic.

Example: ={{ $json.name }} for name, and fallback empty arrays for roles and tools if missing.

5. Define the main AI agent with authorized tool checking

Add a Agent node called “Main Agent” to serve as the personal assistant for the Telegram user. Configure its system message to include the user’s name and instruct it to only use connected tools (no general knowledge). It connects to tools like:

  • Wikipedia (for knowledge lookup)
  • Calculator (for math calculations)

Before these tools reach the agent, they pass through a Code node named “Check permissions” that receives allowed tools from Airtable and disables unauthorized tools by overriding their responses.

This dynamic tool filtering is unique to this workflow, ensuring security inside AI sessions.

6. Attach memory nodes to keep session context

Use Simple Memory nodes linked to user session keys based on Telegram user IDs to store conversation context dynamically. This maintains smooth, context-aware interactions for each user.

7. Add reply node to send back AI results via Telegram

Use a Telegram node configured to send messages to the user’s chat ID with the AI’s response output.

8. Build a sub-agent for weather-related queries

To handle specialized tasks like weather info, another Agent node called “Weather Agent” is configured just like the main one, including its own memory node and permission checking. It connects to tools like:

  • HTTP Request nodes for geocoding city names and fetching current weather data

This sub-agent runs as a separate workflow triggered internally by the main workflow, passing session ID, input, and allowed tools.

9. Use custom code nodes for tool listing

Special ToolCode nodes “list_granted_roles” and “list_allowed_tools” contain JavaScript to convert roles and tools arrays into human-readable strings for use in conversations.

10. Test end-to-end from Telegram

Send messages through your Telegram bot and watch how the workflow fetches permissions, restricts tools accordingly, and replies with relevant answers.

Customizations ✏️

  • Change AI models: In the “OpenAI Chat Model” node, switch to different GPT versions to balance cost and accuracy.
  • Add more tools: Connect more Langchain tool nodes like databases or custom APIs, then update permissions in Airtable accordingly.
  • Adjust permission fields: Modify Airtable to include more granular permission fields, and update the “Check permissions” code node to handle them.
  • Customize Telegram reply formats: Change the “Reply with results” node to send richer messages like images or buttons.
  • Extend session memory duration: Configure “Simple Memory” nodes with larger window sizes or external storage for longer context retention.

Troubleshooting 🔧

  • Problem: “No data found from Airtable for user.”


    Cause: Username mismatch or missing Airtable record.


    Solution: Verify usernames in Telegram and Airtable match exactly; update Airtable records.
  • Problem: “You are not authorized to use this tool” appears unexpectedly.


    Cause: Tool name mismatch or permissions array incorrectly set.


    Solution: Check tool names in Airtable “allowed_tools” field; ensure they exactly match node tool names.
  • Problem: Telegram messages not triggering workflow.


    Cause: Missing Telegram bot credentials or webhook misconfiguration.


    Solution: Re-enter Telegram API credentials; check webhook URLs in Telegram Bot settings.

Pre-Production Checklist ✅

  • Ensure Telegram bot is active and receiving messages.
  • Validate Airtable base and table fields match node configurations.
  • Test permission retrieval with multiple usernames.
  • Run workflow with test Telegram chats for authorized and unknown users.
  • Backup your Airtable permission data regularly.

Deployment Guide

Activate the workflow within your n8n environment and keep an eye on the workflow’s execution logs for any errors. Telegram messages directly trigger permission checks. Monitor the Telegram responses to ensure proper denying or acceptance of tool usages.
Consider setting up environment monitoring for your OpenAI API usage and Airtable query limits. This simple workflow does not require complex multi-node orchestration for deployment.

Conclusion

By following this guide, you’ve built a secure agent access control system that integrates Telegram messaging, Airtable permission management, and AI conversational agents within n8n. This provides a seamless, automated way to manage who can use which AI tools, saving hours of manual oversight and reducing costly errors due to unauthorized requests.

Next, consider automations that extend role-based content filtering, add more AI agents for other departments, or connect different messaging platforms like Slack for a broader reach.

Now, you have a powerful foundation for managing AI tool access in your workflows, making your team’s digital interactions safer and more efficient. Keep experimenting and customizing your agents to fit your exact needs!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free