Telegram lets your flow live inside the world’s most popular messaging app. You create a bot with @BotFather, connect it once, and any DM sent to that bot becomes a conversation in your flow.Documentation Index
Fetch the complete documentation index at: https://docs.cogniagent.ai/llms.txt
Use this file to discover all available pages before exploring further.
When to use Telegram
- Consumer-facing support or assistant bots where your audience already lives in Telegram.
- International / emerging-market audiences where Telegram has higher reach than Slack or Teams.
- Lightweight bots that don’t need a website or login — just
t.me/your_botand people can chat. - Group-channel companions where the bot answers questions when DM’d.
Responder mode only
Telegram is a responder-only channel. The bot can reply to anyone who has messaged it, but it cannot cold-start a conversation with a user it has never met.This is a Telegram platform restriction, not a CogniAgent one. Telegram’s Bot API does not expose a way to look up users by
@username for DM purposes — bots can only send messages to chats they have already received a message in. The standard workaround is a deep link like t.me/your_bot?start=welcome, which a user clicks first; once they tap Start, your bot has their chat_id and can talk.Before you start
You need two things:- A bot token from @BotFather on Telegram.
- A builtin Composio Telegram connection in CogniAgent that holds the token.
Create the bot with @BotFather
Open @BotFather in Telegram
Search for
@BotFather and start a chat. It’s the official bot for creating other bots.Send /newbot
BotFather asks for:
- A display name (what users see, e.g. “Acme Support”).
- A username ending in
bot(e.g.acme_support_bot).
Copy the token
BotFather replies with a token of the form
1234567890:ABCdef.... Keep this safe — anyone with the token can impersonate your bot.(Optional) Configure the bot
While you’re in BotFather you can also set:
/setdescription— the “About” blurb users see before they start the chat./setuserpic— a profile photo./setprivacy—Disableif you want the bot to read all messages in groups it’s added to (not just@mentions). Default isEnable(only sees@mentions).
Add the Telegram channel and connect the bot
The Telegram connection is created from inside the channel-add flow — there’s no separate trip to the Integrations page first.Open the flow's Channels configuration
Go to Conversations → open the flow → Configuration → Channels tab.
Create (or pick) a Telegram connection
The channel form’s Connection field lets you either pick an existing Telegram connection or create a new one inline. When creating new, the form asks for an API Key — paste the BotFather token here. The form’s description text walks through the BotFather flow if you skipped it above.
How conversations are scoped
Each conversation is keyed bychat_id : from_user_id — the chat the message arrived in and the user who sent it.
| Scenario | Conversation |
|---|---|
| Sarah DMs the bot | One conversation (her chat_id == her user id) |
| Sarah DMs the bot again next week | Same conversation (subject to session timeout) |
| Mike DMs the same bot | A separate conversation |
Bot is added to a group; Sarah and Mike both @mention it | Two separate conversations (one per user) inside the same group chat |
Outbound formatting (MarkdownV2)
The bot sends replies withparse_mode: MarkdownV2. The flow’s actor prompt is auto-augmented to nudge the LLM toward MarkdownV2-safe output, but a few quirks are worth knowing:
- Single-delimiter bold:
*bold*(not**bold**). - Single-delimiter italic:
_italic_. - Reserved characters must be backslash-escaped when used as literal text:
So a literal
1.5should be written1\.5, andhttps://example.com/pathshould escape the dot too. - Code spans use backticks. Triple backticks for fenced code blocks (with an optional language tag) work the same as GitHub.
Rich content
| Element | Telegram |
|---|---|
| Plain text | ✓ |
| Bold / italic | ✓ (MarkdownV2) |
| Links | ✓ |
| Bullet lists | ✓ (rendered as plain text with -) |
| Code blocks | ✓ (fenced) |
| Inline buttons | not in v1 |
| Images / attachments | links only in v1 |
| Voice notes | — |
How polling works
There is no Telegram webhook to host — the platform polls Telegram’sgetUpdates API every 5 seconds with an offset bookmark stored in Redis. Updates older than 24 hours that have never been claimed get garbage-collected by Telegram, so the worst-case delivery delay is bounded.
If you previously set a webhook on the same bot (via setWebhook), Telegram refuses to serve getUpdates and returns HTTP 409. The poller logs this as a warning. To resolve, call https://api.telegram.org/bot<TOKEN>/deleteWebhook once and the poller resumes.
Per-user identity
Inbound messages carry the sender’s:from_id— numeric Telegram user id.from_username— the@handle, if set (optional in Telegram).from_first_name/from_last_name— display name parts.
participantName (e.g. "Sarah Lee" or "@sarah_lee" if no real name is set) which actors can reference in their prompts.
Limitations
Troubleshooting
| Symptom | Likely cause |
|---|---|
| No conversations appear after deploy | The bot hasn’t received any DMs yet. Send /start from your own account to @your_bot to trigger the first one. |
| Bot replies stop after a redeploy | A previously-set webhook is intercepting updates. Call deleteWebhook once. |
Replies render as literal characters (\., \!) | The model emitted text that doesn’t satisfy MarkdownV2 escaping. Usually self-corrects on the next turn; consider tightening the actor’s system prompt. |
| Multiple users in one group share state | Privacy mode is off but the actor wasn’t designed for group context. Either turn privacy back on (so the bot only hears @mentions) or have the actor handle the multi-speaker case explicitly. |
| New session created on every message | Session timeout is shorter than the gap between user messages. Increase it in Flow settings. |
Next
Messaging channels
Slack and Teams — the closest cousins of Telegram.
Deploy a flow
Schedule the Telegram listener.
