Implement a secure authorization layer for your Telegram bot using this n8n workflow. Whitelist users via a custom n8n node and instantly alert multiple administrators on unauthorized access attempts. Protect your paid API credits and resources.
Download this n8n workflow template and start using it instantly.
Running a public bot without an authorization layer can be costly and risky, especially if the bot consumes paid resources like AI credits or heavy server processing time. This powerful n8n workflow, dubbed 'BotGuard,' solves this critical problem by implementing a simple yet effective whitelist security layer directly within your automation flow.
This specific n8n workflow starts with an n8n trigger (Telegram) and immediately processes the user's ID against defined whitelists using a custom Code n8n node. If unauthorized access occurs, the user receives a tailored denial message (complete with their user ID for easy whitelisting), and all configured administrators receive an instant, detailed alert about the breach attempt. This ensures you maintain control over resource consumption and security. It's an essential piece of core logic flow control for any serious Telegram automation using n8n.
This authorization n8n workflow follows a strict security path:
AllowedUsers array and the Administrators array (both defined within the node). It calculates the authorization status and generates three possible messages: success, denied, and admin alert.allowEntry flag created in the previous step. allowEntry is true, the flow proceeds to 'Send Success', confirming authorization to the user. After this step, you would typically integrate your main processing logic (e.g., calling an OpenAI API).allowEntry is false, the user receives the 'Send Denied' message, which includes the denied user's ID.To deploy this specialized n8n workflow template, follow these steps:
AllowedUsers and Administrators arrays at the top of the code block. Crucially, replace the placeholder IDs with the actual User IDs and corresponding usernames for your authorized users and administrators. Telegram Trigger (n8n trigger): Initiates the entire n8n workflow whenever a message is received by your configured Telegram bot.
BotGuard Authorization (Code n8n node): The core logic. This custom n8n node defines whitelists (AllowedUsers and Administrators), extracts user details, checks the user ID against the whitelist, and generates dynamic response messages based on the outcome. It sets the botGuard.allowEntry flag.
Check Authorization (If n8n node): A key piece of core logic flow control. It evaluates the botGuard.allowEntry value to determine if the user's request should be processed or blocked.
Send Success / Send Denied (Telegram n8n node): Handles communication back to the user, sending either the welcome message or the denial message (which instructs the user on how to request access).
Check Admin Notify (If n8n node): Ensures that admin alerts are only processed if an actual unauthorized access attempt occurred (i.e., adminMessage is not empty).
Prepare Admin Notifications (Code n8n node): This advanced Code n8n node processes the list of administrators and clones the flow data for each admin. This ensures that a single notification attempt reaches multiple administrative chat IDs, leveraging the powerful item processing capabilities of n8n.
Enhance your development experience in n8n by adding TypeScript-like Intellisense to the Code n8n node using JSDoc definitions. Essential for complex n8n workflow scripting.

Use this powerful n8n workflow and LangChain AI agent to converse naturally with a bot, automatically creating and logging project tasks directly into Google Sheets. Leverage n8n templates for instant task automation.

Automate content enrichment using this powerful n8n workflow. Fetch WordPress articles, generate AI summaries via GPT-4.1, and update posts automatically. Ideal for content marketing teams.

Use this robust n8n workflow to automatically add events to your Google Calendar. Perfect for testing recurring tasks or simple scheduling using the Google Calendar n8n node.


Professional Product Director that cought vibe of Automaion and Solo Programming and Context Aware AI Vibe coding.







































