Trigger n8n Workflows from Telegram
Ready to automate?
Browse 5,000+ copy-paste n8n workflow templates.
Most n8n workflows are reactive: a Stripe payment arrives, a form is submitted, a scheduled timer fires. But sometimes you need to start a workflow on demand — from your phone, while you're away from your laptop.
Telegram gives you a free, always-on messaging interface with a robust bot API. Combined with n8n's Telegram Trigger node, you can build a command bot that listens for messages, routes them to different workflow branches, and replies with results in seconds.
This guide walks you through building a working Telegram command bot in n8n: creating the bot, wiring up the trigger, routing commands with the Switch node, and sending responses back.
What You'll Build
A Telegram bot that accepts three commands:
/status— pings a health endpoint and reports whether a service is up/report— queries a Google Sheets table and returns a formatted summary/approve [id]— marks an Airtable record as approved and confirms back
The same skeleton scales to any command you need. Adding a new one means adding one branch to the Switch node — nothing else changes.
Prerequisites
- A self-hosted or n8n Cloud instance with the workflow activated
- A Telegram account
- API credentials for whichever services your commands will call
Step 1: Create the Bot with BotFather
Open Telegram and message @BotFather. Send /newbot, choose a display name, and pick a username (must end in bot). BotFather returns an API token like 7312456789:AAF-.... Save it.
You'll also need your Chat ID — the numeric identifier n8n uses to send replies back to you. After starting a conversation with the new bot, open https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates in a browser. Send any message to the bot first, then refresh the URL. The message.chat.id field in the JSON is what you need.
Step 2: Configure the Telegram Trigger in n8n
Create a new workflow. Add a Telegram Trigger node as the starting node.
- Create a new Telegram credential using the bot token from BotFather.
- Set the Updates field to "Message."
- Save and activate the workflow — n8n will begin polling the Telegram Bot API for new incoming messages.
The trigger outputs the full Telegram update object. The fields you'll use most are message.text (the command text) and message.chat.id (who sent it).
Step 3: Extract the Command and Arguments
Add a Set node immediately after the trigger. Define three fields:
- command — expression:
{{ $json.message.text.split(' ')[0] }}— extracts just the command keyword (e.g./status,/approve) - chatId — expression:
{{ $json.message.chat.id }} - args — expression:
{{ $json.message.text.split(' ').slice(1).join(' ') }}— captures anything after the command, such as a record ID
This keeps downstream nodes clean. They read command, chatId, and args directly instead of parsing raw Telegram JSON.
Step 4: Route Commands with the Switch Node
Add a Switch node after the Set node. Set the value to evaluate as the command field, and create one output rule per command:
- Output 0: value equals
/status - Output 1: value equals
/report - Output 2: value equals
/approve - Fallback output: everything else
Connect each output to its branch. Connect the fallback to a Telegram node that replies "Unknown command. Try /status, /report, or /approve."
The Switch node makes the routing logic explicit and easy to extend.
Example n8n Workflow: Three Branches
Branch 1 — /status
- HTTP Request node — sends a GET request to your service's health endpoint or any uptime URL.
- IF node — checks the HTTP status code. Route 200 responses to a success message; anything else to a failure message.
- Telegram node (two instances, one per IF branch) — sends back the result, e.g. "Service is up. Response: 142ms." or "Service is down. Check the logs."
Branch 2 — /report
- Google Sheets node — reads rows from a named sheet (e.g., the past week of sales, task completions, or form submissions).
- Code node — aggregates the rows into a single summary string: total count, sum of a column, or the most recent entry date.
- Telegram node — sends the formatted summary back to the
chatIdfrom the Set node.
Branch 3 — /approve [id]
- Set node — reads
argsand assigns it to a cleaner variable likerecordId. - Airtable node — updates the matching record's Status field to "Approved."
- IF node — checks whether the Airtable update returned a record (handles the case where the ID doesn't exist).
- Telegram node — replies "Record [id] approved." or "Record not found." depending on the IF result.
Restricting Access to Authorized Users
By default, anyone who discovers your bot can send it commands. Add an IF node immediately after the Telegram Trigger — before the Set node — that compares message.chat.id against a hardcoded allowlist. If the ID isn't on the list, end the execution there.
For team bots with multiple authorized users, store the allowed Chat IDs in a Google Sheet or environment variable and load them with an additional node at the start of the workflow. This way you can add or remove users without editing the workflow.
When to Use This Pattern
A Telegram command bot is useful whenever:
- You want to trigger an n8n workflow from a mobile device without opening a dashboard
- You need a lightweight approval interface that doesn't require a separate web app
- You want to let non-technical teammates trigger specific automations with simple commands
- You're building personal productivity tools and want a conversational trigger layer
Concrete examples from teams already using this pattern: on-call engineers using /deploy staging to kick off deployment workflows, agency ops teams using /invoice [client] to generate and send a PDF, and founders using /mrr to pull a live revenue snapshot from Stripe.
Going Further
The three-branch structure here is a starting point. n8n's Switch node supports unlimited outputs, so you can add as many commands as your team needs. Each branch is a fully independent sub-workflow with its own error handling, data transformations, and integrations.
The command routing pattern also works with n8n's Slack Trigger and Discord Trigger nodes if your team prefers those platforms — the Switch and Set node logic is identical.
Browse the full template library at n8nresources.dev/templates to find pre-built workflows you can adapt as branches in your bot. If you're building approval-style commands, the patterns on the approval workflows page are worth reviewing alongside this guide.
Enjoyed this article?
Share it with others who might find it useful