How to connect a Telegram agent
This guide takes you from a fresh Telegram bot to a working agent: someone messages your bot, your Agent answers, the reply lands back in Telegram, and the conversation is remembered across messages.
Prerequisites
Section titled “Prerequisites”- An agent flow shaped like
Webhook → Agent → Channel/Telegram reply. The Telegram support agent template is wired this way, with its Webhook node named Telegram inbound, and is the easiest starting point. - A Telegram account (to create the bot and to chat with it).
- An LLM provider key for the Agent (for example an OpenAI key).
1. Create the bot
Section titled “1. Create the bot”In Telegram, open a chat with @BotFather, send /newbot, and follow the prompts. BotFather gives you a bot token that looks like 8012345678:AAH…. Keep it handy.
2. Store the secrets
Section titled “2. Store the secrets”Your flow reads the bot token from a secret, so it never lives in the flow definition. In your workspace, go to Secrets and create an opaque secret:
| Secret name | Slug the flow expects | Value |
|---|---|---|
telegramBotToken |
telegrambottoken |
the BotFather token |
The Telegram node reads it as {{ $secrets->telegrambottoken }}. Name the secret exactly as above so the slug matches.
The agent pays for its model with the workspace’s key for the provider, set on the AI models page, so add one there if the workspace has none. To pay with another key, pick the secret that holds it in the Agent node’s credential field.
3. Create a webhook and point the trigger at it
Section titled “3. Create a webhook and point the trigger at it”Telegram delivers messages to an inbound webhook URL. That URL is tied to a webhook, and the Webhook node that starts your flow must reference the same one.
-
Go to Webhooks and create a new webhook. Use Copy beside the address under its name to copy the full inbound URL, and note its ID, the address’s last part.


-
Open your flow, click the Webhook node (Telegram inbound in the template), and pick that webhook in its Webhook field. Click Save changes.
4. Register the URL with Telegram
Section titled “4. Register the URL with Telegram”Tell Telegram where to send messages by calling setWebhook once with your bot token and the URL you copied from the webhook:
curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=<COPIED_WEBHOOK_URL>"A successful response is {"ok":true,"result":true,"description":"Webhook was set"}.
5. Message your bot
Section titled “5. Message your bot”Send your bot a message in Telegram, for example “Hi! What can you help with?”. Within a few seconds it replies with the agent’s response.
Voice messages. The agent hears a voice note through its attachments field, which the template sets to {!! json_encode($start->attachments) !!}. Keep it: a voice note has no text, and on Telegram a transcript is never put into the message text. The webhook needs the bot token to fetch the note (Connect a channel stores it). When the workspace transcribes Telegram voice notes on arrival (AI models → Voice messages), the agent reads that transcript instead of transcribing the note again.
Verify it works
Section titled “Verify it works”-
Run: in your workspace, open Runs and confirm a run of your flow completed.
-
Reply: the agent’s answer appears in your Telegram chat.
-
The bot: when you connected the bot from an agent’s Connect a channel, its webhook (under Webhooks) holds the token, and Check the bot on the webhook’s page asks Telegram whether the token works and whether it sends the bot’s messages to this webhook.


-
Memory: open Conversations. A thread now exists for this conversation, keyed by the channel, chat, and user, holding both the incoming message and the agent’s reply. Send a second message that refers to the first (tell the bot a fact, then ask about it) and confirm the agent remembers, drawing on that thread.
Troubleshooting
Section titled “Troubleshooting”- Telegram reports
404 Not Found(check withgetWebhookInfo): the Webhook node’s Webhook doesn’t match the webhook whose URL you registered. Point the node at the same webhook, then re-runsetWebhook. - Telegram reports a
500: open the run under Runs for the error. A common cause is an empty or wrong secret. - No reply arrives: confirm the bot token secret holds the right value, that the workspace has a key for the agent’s provider on the AI models page, and that a queue worker is running to process runs.
- Fill in the form says to start a chat with the bot first: Telegram lets a bot write only to someone who has started a chat with it, and the form’s link goes to your own chat with the bot. Open the bot, press Start, then press Fill in the form again.
- The bot answers in a direct chat, but not in a group: Telegram’s privacy mode, on by default, lets a bot in a group hear only commands, replies to its messages and mentions of it. To have it hear every message, turn privacy off with @BotFather (
/setprivacy→ Disable), then remove the bot from the group and add it again.
Related
Section titled “Related”- Connect an agent to a chat channel — the same pattern for Slack, Discord, Teams, and WhatsApp.
- Connect a WhatsApp agent — the other webhook-based channel.
- How to build an AI agent — give the agent tools, memory, and triggers.
- Channel / Telegram · Secrets · Chat Threads.