Building a Telegram Bot with n8n: From Notifications to Conversations
How to build a Telegram bot in n8n: connecting the bot and its webhook, handling commands and buttons, conversation state, groups and channels, Telegram API limits, and what to settle before production.
All articles in the guide n8n · 18
Telegram is the most common interface to automation: no website to build, no new tool to explain to anyone. A bot comes together quickly in n8n, but between “it replies to a message” and “it works for real users” sit a few steps worth taking deliberately.
Connecting
Get the token from BotFather and store it in n8n credentials. The entry point is the Telegram trigger: on activation n8n registers the webhook address with Telegram itself, so there is nothing to configure separately.
The requirement is the same as for any webhook: a public HTTPS address. A local n8n without a domain will not work - Telegram has nowhere to deliver updates. How to stand that up is covered in installation.
This is where the classic mistake begins: built on the test URL, everything worked, closed the editor, bot went silent. The production address only lives on an activated workflow.
What actually arrives
Telegram does not send “the message text” but an update object with everything attached: who wrote, in which chat, what exactly, and whether it was text, a photo, a command or a button press.
Two practical consequences:
- Check the type. A bot expecting text that receives a sticker fails on a missing field - the same data shape problem as everywhere else.
chat.idis your key identifier. You need it to reply, and it doubles as the state key. Do not confuse it with the user id: in a group they are different things.
Commands and buttons
Commands (/start, /help) are ordinary text beginning with a slash, parsed by branching. Register the command list with BotFather so users get a hint instead of guessing.
Inline buttons beat commands almost always: fewer input mistakes and a clearer flow. One important detail - a button press arrives as a different update type than a message. The workflow must handle both, and this is the first thing forgotten when a bot suddenly “ignores the buttons”.
A second nuance: Telegram expects an acknowledgement for a button press. Without it the user is left with a spinning indicator - a small thing that reads as broken.
Conversation state
The key constraint: n8n does not keep state between runs. Every message is its own execution and knows nothing about the previous one.
For linear flows (received, replied) that does not matter. The moment you have a multi-step dialogue - “enter your email”, then “enter your company” - state must live outside, keyed by chat.id: a database, a sheet, or the memory of an AI agent if the flow is conversational.
On agent memory specifically: the session key must be the chat identifier. Skip that and every user shares one context and reads other people’s conversations.
Groups and channels
In a group a bot does not see all messages by default, only those addressed to it - a privacy setting in BotFather. If a bot “stays quiet” in a group, check that first.
For a channel the bot must be an administrator. And remember the difference: posting to a channel is one-way, there is no conversation there.
Telegram’s limits
Two limits that bite as you grow:
Send rate. A broadcast to a list runs into rate limits and Telegram starts returning errors. Since a node runs once per item, a thousand-recipient broadcast is a thousand consecutive calls. You need pauses between sends and retries with backoff on rejection.
Message formatting. If you use markup, special characters inside user-supplied data break it and Telegram rejects the whole message. Either escape interpolated text or do not format anything that came from a user.
Before production
- Answer unexpected input. A sticker, a photo, an empty message, an unknown command - the bot should say something rather than nothing.
- Acknowledge slow operations immediately. If the workflow takes 20 seconds, send “got it” first: a silent bot looks broken.
- Alert yourself on errors. An error workflow is mandatory here: with a bot, users see the failure before you do.
- Test with a second user. State and shared-memory bugs only appear once more than one person is involved.
FAQ
How do I build a Telegram bot in n8n?
Get a token from BotFather, add it to n8n credentials, put the Telegram trigger at the entry point and activate the workflow - n8n registers the webhook with Telegram for you. From there, parse the incoming message and reply with the send node. A production bot needs a public HTTPS address.
Can an n8n bot hold a conversation with memory?
Yes, but n8n does not keep state between runs by itself: every message is a separate execution. State has to live outside and be keyed by chat id - in a database, a sheet, or for AI scenarios in the agent memory with the session key set to the chat identifier.
- n8n: A Complete Practical Guide to Workflow AutomationGuide
- Installing n8n with Docker: Self-Hosting on Your Own ServerHow to stand up n8n on your own server with Docker: compose file, data volume, encryption key, HTTPS and webhooks behind a reverse proxy, moving to PostgreSQL, and what to back up so you never lose credentials.
- Triggers and Webhooks in n8n: How a Workflow StartsTrigger types in n8n and working with webhooks: test URL versus production URL, why a webhook never arrives, responding to the caller, schedules and timezones, and securing a public endpoint.
- Data and Expressions in n8n: Items, $json and Why a Node Runs Many TimesHow data works in n8n: an array of items rather than an object, $json and node expressions, reaching earlier nodes, nested JSON, merging and splitting branches, and the usual empty-data mistakes.
Done for you
I will build the automation in n8n or in code
Leads, sheets, CRM and Telegram connected, so nobody moves data by hand again.
from $300 · 3 to 7 days
"Thanks to Pavel, the task is done. Always reachable, gave me detailed instructions and a guide, I will come back and I recommend him to everyone."