
Setting Up Moltbot with Telegram: Complete Bot API Guide (2026)
Telegram is often the fastest and most stable way to deploy Moltbot. With its robust Bot API and native support for rich features like inline buttons, stickers, and forum topics, Telegram transforms any Moltbot instance into a highly interactive Personal OS.
Whether managing DMs or automating a large group chat, this guide covers every technical detail required to master the Telegram Moltbot integration.
Security Notice
Setting up a messaging integration involves security-sensitive configurations including bot tokens, access controls, and permissions. Always verify configurations against the official documentation and follow security best practices. For the most up-to-date and authoritative guidance, consult the official Moltbot Channels documentation.
Moltbot on Telegram
The Telegram channel is production-ready for bot DMs + groups via grammY. Long-polling is the default; webhook mode is optional. It offers deterministic routing, meaning replies always return to the correct chat, and the model never has to "guess" the delivery channel.
High-Level Features
- Native command registration
- Forum topic / Threading support
- Vision-based sticker caching
- HTML-safe message rendering
- Draft bubble streaming
- Multi-account Bot API support
- Inline keyboards & callbacks
- Reaction notifications (own/all)
Quick Setup (Fast Path)
- 1
Create a Bot with @BotFather
Open Telegram, chat with @BotFather, run
/newbot, and copy the token. - 2
Set the Token
Via environment:
TELEGRAM_BOT_TOKEN=...
Or via config:channels.telegram.botToken: "..."
(If both are set, config takes precedence; env fallback is default-account only.) - 3
Start the Gateway
DM access is pairing by default; approve the pairing code on first contact.
Minimal Config
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123:abc",
"dmPolicy": "pairing"
}
}
}How It Works
Session Routing
DMs share the agent's main session.
Groups stay isolated as agent:<agentId>:telegram:group:<chatId>.
Deterministic Routing
Replies go back to Telegram; the model never chooses channels.
Long-Polling vs Webhook
Default: long-polling (no public URL required). Webhook mode: set channels.telegram.webhookUrl.
Formatting (Telegram HTML)
Outbound Telegram text uses parse_mode: "HTML". Markdown input is rendered into Telegram-safe HTML. If Telegram rejects the HTML payload, Moltbot retries as plain text.
Creating Bot Token (BotFather)
- 1
Begin Chat
Find @BotFather on Telegram and send
/newbot. Follow the prompts (name + username ending inbot). - 2
Secure Token
Copy the token and store it safely. If a token leaks, revoke/regenerate it via @BotFather and update the config.
- 3
Optional BotFather Settings
/setjoingroups— allow/deny adding the bot to groups./setprivacy— control whether the bot sees all group messages.
Privacy Mode & Groups
Group Message Visibility
Telegram bots default to Privacy Mode, which limits which group messages they receive. If the bot must see all group messages:
- Option 1:Disable privacy mode with
/setprivacyin @BotFather. - Option 2:Add the bot as a group admin (admin bots receive all messages).
Note: When privacy mode is toggled, Telegram requires removing + re-adding the bot to each group for the change to take effect.
Access Control (DMs + Groups)
DM Access
Default: dmPolicy = "pairing". Unknown senders receive a pairing code (expires after 1 hour).
moltbot pairing approve telegram <CODE>
Policy Options:
pairing(default, recommended)open+allowFrom: ["*"]allowlist+allowFrom: [...]disabled
Group Access
Two independent controls:
1. Which groups are allowed:
- No
groupsconfig = all groups allowed - With
groupsconfig = only listed groups or"*"
2. Which senders are allowed (groupPolicy):
open= all sendersallowlist= onlygroupAllowFrom(default)disabled= no group messages
Finding Your Telegram User ID
- Safest: Start the gateway, DM the bot, run
moltbot logs --follow, look forfrom.id. - Official Bot API: DM the bot, then fetch updates:
curl "https://api.telegram.org/bot<token>/getUpdates" - Third-party: DM
@userinfobotor@getidsbot.
Group Activation Modes
By default, the bot only responds to mentions in groups (@botname or patterns in mentionPatterns). To change this behavior:
{
"channels": {
"telegram": {
"groups": {
"-1001234567890": { "requireMention": false }, // always respond
"*": { "requireMention": true } // default for all other groups
}
}
}
}Key Notes:
- Setting
groupscreates an allowlist — only listed groups (or"*") are accepted. - Forum topics inherit parent group config unless per-topic overrides are added.
- Quick test (session-only):
/activation alwaysin the group.
Getting the group chat ID: Forward any message from the group to @userinfobot or @getidsbot.
Native & Custom Commands
Moltbot registers native commands like /status, /reset, /model with Telegram's bot menu on startup. Custom commands can be added via config:
{
"channels": {
"telegram": {
"customCommands": [
{ "command": "backup", "description": "Git backup" },
{ "command": "generate", "description": "Create an image" }
]
}
}
}Notes:
- Custom commands are menu entries only; Moltbot does not implement them unless handled elsewhere.
- Command names are normalized (leading
/stripped, lowercased) and must matcha-z,0-9,_(1–32 chars). - Custom commands cannot override native commands. Conflicts are ignored and logged.
Inline Buttons & Callbacks
Telegram supports inline keyboards with callback buttons. When a user clicks a button, the callback_data is delivered back to the agent as a message.
{
"action": "send",
"channel": "telegram",
"to": "123456789",
"message": "Choose an option:",
"buttons": [
[
{"text": "Yes", "callback_data": "yes"},
{"text": "No", "callback_data": "no"}
],
[
{"text": "Cancel", "callback_data": "cancel"}
]
]
}Inline Button Scopes
off— inline buttons disableddm— only DMs (group targets blocked)group— only groups (DM targets blocked)all— DMs + groupsallowlist(default) — DMs + groups, but only senders allowed byallowFrom/groupAllowFrom
Sticker Caching & Search
Moltbot supports receiving and sending Telegram stickers with intelligent caching. When a user sends a Static Sticker (WEBP), Moltbot uses vision to describe it. This description is saved to sticker-cache.json.
Receiving Stickers
- Static (WEBP): Downloaded and processed through vision.
- Animated (TGS): Skipped (Lottie format not supported).
- Video (WEBM): Skipped (video format not supported).
Sending Stickers
Enable via actions.sticker: true. The agent can:
action: "sticker"— send a sticker by fileIdaction: "sticker-search"— search cached stickers
Forum Topics & Threading
Telegram forum topics include a message_thread_id per message. Moltbot appends :topic:<threadId> to the session key so each topic is isolated. Topic-specific configuration is available under channels.telegram.groups.<chatId>.topics.<threadId>.
Reply Threading: Use tags [[reply_to_current]] or [[reply_to:<id>]]. Controlled by replyToMode: first (default), all, off.
Draft Streaming
Telegram can stream draft bubbles while the agent is generating a response (Telegram Bot API 9.3+). Moltbot uses sendMessageDraft and then sends the final reply as a normal message.
Stream Mode Options
partial— update the draft bubble with the latest streaming text.block— update the draft bubble in larger blocks (chunked).off— disable draft streaming.
Streaming works in private chats with topics enabled (forum topic mode). Ignored for groups/supergroups/channels.
Reaction Notifications
Telegram reactions arrive as separate message_reaction events. Moltbot converts them to system events and enqueues them in the conversation history.
{
"channels": {
"telegram": {
"reactionNotifications": "all", // off | own | all
"reactionLevel": "minimal" // off | ack | minimal | extensive
}
}
}reactionNotifications: "own"(default) — notify when users react to bot messages.reactionLevel: "ack"(default) — bot sends 👀 while processing.
Audio Messages (Voice vs File)
Telegram distinguishes voice notes (round bubble) from audio files (metadata card). Moltbot defaults to audio files for backward compatibility.
Voice Note Tag
To force a voice note bubble in agent replies, include [[audio_as_voice]] anywhere in the reply. The tag is stripped from the delivered text.
For message tool sends, set asVoice: true with a voice-compatible audio media URL.
Limits & Retry Policy
Messaging Limits
- Text chunking:
textChunkLimit(default 4000) - Media cap:
mediaMaxMb(default 5 MB) - API timeout:
timeoutSeconds(default 500)
History Limits
- Group history:
historyLimit(default 50) - DM history:
dmHistoryLimit(user turns) - Per-user overrides:
dms["<id>"].historyLimit
Retry Policy
Outbound Telegram API calls retry on transient network/429 errors with exponential backoff and jitter. Configure via channels.telegram.retry.
Full Config Reference
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123:abc",
"dmPolicy": "pairing",
"allowFrom": ["123456789"],
"groupPolicy": "allowlist",
"groupAllowFrom": ["987654321"],
"textChunkLimit": 4000,
"chunkMode": "length",
"mediaMaxMb": 5,
"historyLimit": 50,
"replyToMode": "first",
"streamMode": "partial",
"linkPreview": true,
"reactionNotifications": "own",
"reactionLevel": "ack",
"groups": {
"*": { "requireMention": true },
"-1001234567890": {
"requireMention": false,
"skills": ["search", "docs"],
"systemPrompt": "Keep answers short.",
"topics": {
"123": { "requireMention": true }
}
}
},
"capabilities": {
"inlineButtons": "allowlist"
},
"actions": {
"reactions": true,
"sendMessage": true,
"deleteMessage": true,
"sticker": false
},
"retry": {
"attempts": 3,
"minDelayMs": 500,
"maxDelayMs": 30000,
"jitter": 0.1
},
"customCommands": [
{ "command": "backup", "description": "Git backup" }
]
}
}
}Troubleshooting
Conclusion
The Telegram integration represents one of the most feature-complete channels in the Moltbot ecosystem. By mastering @BotFather configurations and utilizing features like vision-based sticker caching and forum topic isolation, an AI experience that feels truly integrated into digital life can be created.
Ready to level up? Check out the guides for WhatsApp and iMessage to build a true multi-channel personal assistant.



