OpenClaw टेलीग्राम बॉट सेटअप: कमांड्स, रूटिंग, और मल्टी-एजेंट सेशन्स

हे ऑटोमेशन बिल्डर्स — अगर आप OpenClaw को टेलीग्राम से जोड़ रहे हैं और सोच रहे हैं कि जब मैसेज डीएम, ग्रुप्स, और टॉपिक्स से आने लगते हैं तो रूटिंग कैसे काम करती है, तो साथ बने रहें।
मैंने पिछले दो हफ्ते OpenClaw को तीन अलग-अलग सेटअप में टेलीग्राम के जरिए चलाया: व्यक्तिगत डीएम, टीम ग्रुप्स, और फोरम टॉपिक्स। डेमो परिदृश्य नहीं। वास्तविक रूटिंग परीक्षण जहां मैंने जानबूझकर सेशन आइसोलेशन को तोड़ा, इसे समवर्ती अनुरोधों से भर दिया, और देखा कि गेटवे ने मल्टी-अकाउंट कॉन्फ़िग्स को कैसे संभाला।
जिस प्रश्न पर मैं बार-बार वापस आया: क्या यह वास्तव में स्वच्छ सेशन बाउंड्रीज़ बनाए रख सकता है जब आप कई चैट्स को मैनेज कर रहे हों, या यह सब एक गंदे बातचीत थ्रेड में बदल जाता है?
यहाँ मैंने क्या पाया, साथ ही सटीक कॉन्फ़िग पैटर्न जो सफल रहे।
संदर्भ के लिए, OpenClaw (पहले Moltbot और Clawdbot) ने 2026 की शुरुआत में एक ओपन-सोर्स स्वायत्त AI सहायक के रूप में 100,000 से अधिक GitHub सितारे प्राप्त किए। इसे पीटर स्टीनबर्गर द्वारा बनाया गया था, यह मैसेजिंग प्लेटफार्म्स जैसे टेलीग्राम को AI एजेंट्स से जोड़ता है जो लोकली या निजी सर्वर पर चलते हैं।

एक टेलीग्राम बॉट बनाएं (BotFather के जरिए)
Every OpenClaw Telegram setup starts with @BotFather, Telegram's official bot creation interface. This hasn't changed since Telegram launched bots — it's still the only way to generate API tokens.
What you'll need:
- Active Telegram account (phone verification required)
- 3 minutes for initial setup
- Bot token stored somewhere secure (I use a password manager)

Step-by-step bot creation
- Open Telegram and search for @BotFather
- Verified account has a blue checkmark
- Send
/startto see available commands
- Create new bot with
/newbot- Bot name: What users see in conversations (can include spaces)
- Username: Must end with
bot(e.g.,YourProjectBot) - Username must be globally unique across Telegram
- Save your API token immediately
- Format:
123456789:ABCdefGHIjklMNOpqrsTUVwxyz - Treat this like a password — anyone with this token controls your bot
- If compromised, use
/revokein BotFather to generate a new one
- Format:
Critical BotFather settings (optional but recommended):
/setjoingroups → Allow/deny adding bot to groups
/setprivacy → OFF = bot sees all group messages
ON = bot only sees mentions and commands
I learned this the hard way: if you set privacy to ON and wonder why your bot ignores group messages, that's why. OpenClaw's routing expects full message access by default.
Connect Token + Verify Updates
Getting the token into OpenClaw is where most setup guides stop — but that's where real testing should start.
Basic connection config
OpenClaw supports two token input methods:
Environment variable (quick testing):
export TELEGRAM_BOT_TOKEN="your_token_here"
openclaw gateway
Config file (production approach):
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "123456789:ABCdefGHIjklMNOpqrsTUVwxyz",
"dmPolicy": "pairing"
}
}
}
Verification test sequence
Here's the sequence I run every time to confirm the Gateway actually sees Telegram updates:
- Start Gateway with logging:
openclaw gateway --log-level debug
- Send
/startto your bot in Telegram- Should trigger pairing flow if
dmPolicy: "pairing" - Check terminal for incoming update logs
- Should trigger pairing flow if
- Monitor update stream:
openclaw logs --follow
Common failure point: Bot token typo. If you see 401 Unauthorized in logs, regenerate the token in BotFather and update your config. Don't waste an hour troubleshooting like I did.
सुरक्षा नोट: उत्पादन परिनियोजन के लिए, DigitalOcean के सख्त OpenClaw छवि का उपयोग करने पर विचार करें, जिसमें फायरवॉल नियम, कंटेनर अलगाव, और डिफ़ॉल्ट रूप से गैर-रूट निष्पादन शामिल है।
कमांड डिज़ाइन जो स्केल करता है

OpenClaw की कमांड प्रणाली वह जगह है जहां रूटिंग लॉजिक मायने रखता है। गेटवे सभी चैनलों में स्लैश कमांड को पहचानता है, लेकिन Telegram अपनी खुद की कमांड ऑटोकम्प्लीट लेयर जोड़ता है।
आधिकारिक OpenClaw रिपॉजिटरी में पूरा कमांड सेट प्रलेखित है, लेकिन वास्तविक दुनिया परीक्षण के बाद, केवल कुछ ही आवश्यक साबित होते हैं।
मुख्य कमांड पैटर्न
ये वे कमांड हैं जिनका मैं उत्पादन सेटअप में वास्तव में उपयोग करता हूँ (पूरा सूची नहीं — बस वही जो वास्तविक उपयोग में जीवित रहते हैं):
Important: /activation always only affects the current session. To persist it, add it to your config's requireMention settings.
Setting up custom commands in BotFather
This is what makes your bot feel native in Telegram:
- In BotFather:
/mybots→ Select your bot →Edit Commands - Send command list (one per line):
new - Start fresh sessionstatus - Check session statehelp - Show all commands
- These appear in Telegram's
/autocomplete menu
Reality check: I initially set up 15 commands. After two weeks, I only use 4. Start minimal.
For deeper understanding of Telegram's bot architecture, see the official Telegram Bot tutorial which covers the Bot API fundamentals.
Routing by Chat/User/Topic

This is where OpenClaw's session architecture either makes sense or falls apart. Session keys determine whether conversations stay isolated or bleed together.
Session key structure
OpenClaw generates session keys using this pattern:
agent:<agentId>:telegram:<chatType>:<chatId>[:topic:<topicId>]
Breakdown:
- DMs: All messages from one user → shared
mainsession - Groups: Each group → isolated session (
telegram:group:<chatId>) - Forum topics: Each topic → separate session (
:topic:<threadId>suffix)
Multi-account routing config
Here's a real config I ran for testing three separate Telegram bots routing to different agents:
{
"channels": {
"telegram": {
"accounts": [
{
"name": "personal",
"botToken": "token1...",
"routing": { "agent": "main" }
},
{
"name": "work",
"botToken": "token2...",
"routing": { "agent": "work-agent" }
},
{
"name": "testing",
"botToken": "token3...",
"routing": { "agent": "sandbox" }
}
]
}
}
}
Each account routes to a separate agent workspace with independent memory and tools. No cross-contamination.
Group routing with mention controls
Default behavior: groups require @mention to trigger responses. Override per-group:
{
"channels": {
"telegram": {
"groups": {
"*": { "requireMention": true },
"-1001234567890": {
"requireMention": false
}
}
}
}
}
Group ID discovery: Add bot to group, send a message, check openclaw logs --follow for the chat.id value (always negative for groups).
Forum topic isolation

Telegram forums add message_thread_id to messages. OpenClaw appends :topic:<threadId> to session keys automatically.
Critical edge case I hit: Topic ID 1 (general topic) requires special handling. OpenClaw omits message_thread_id when sending to topic 1 because Telegram rejects it.
Config example for per-topic system prompts:
{
"telegram": {
"groups": {
"-1003595003457": {
"requireMention": false,
"topics": {
"14": {
"requireMention": false,
"systemPrompt": "You are a coding assistant."
},
"27": {
"systemPrompt": "You focus on deployment issues."
}
}
}
}
}
}
Each topic maintains isolated conversation history.
Debugging Missed Messages
When messages disappear into the void, it's usually one of these three culprits.
Diagnostic checklist
- Check BotFather privacy settings
/mybots → Your Bot → Bot Settings → Group Privacy → OFF
- If ON, bot only sees mentions — not regular messages.
- Verify group whitelist
openclaw logs --follow | grep "skipping group message"
- If
channels.telegram.groupsis defined, unlisted groups are ignored. - Confirm bot membership
- Bot must be added as a member (not just admin with no read access)
- Test: send a message, check if bot's "last seen" timestamp updates
- Review Gateway logs
openclaw logs --level debug --filter telegram
Common routing failures
Session hygiene checks
I run this sequence weekly to catch routing drift:
# List active sessions
openclaw sessions list
# Check specific session state
openclaw sessions show <sessionKey>
# Force session cleanup (last resort)
openclaw sessions prune --older-than 7d
When sessions leak: If you see context bleeding between chats, it's usually a config error where multiple chats map to the same session key. Review channels.telegram.accounts[].routing.agent settings.
What Actually Worked Long-Term
After two weeks of daily use across three different Telegram setups, here's what survived:
Stable config pattern
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "env:TELEGRAM_BOT_TOKEN",
"dmPolicy": "pairing",
"groups": {
"*": { "requireMention": true }
}
}
}
}
Why this works:
- DM pairing prevents unauthorized access
- Wildcard group policy with mention requirement = safe defaults
- Token from env var = easier rotation without touching config
What didn't scale
- Custom commands beyond
/new,/status,/help— Users forget them - Per-topic system prompts — Maintenance burden grows fast
- Multiple accounts without clear routing rules — Session chaos
Boundary conditions
OpenClaw Telegram routing is solid for:
- Personal DM automation (single user)
- Small team groups (< 20 active members)
- Forum topics with distinct purposes
It gets messy when:
- You're managing 10+ groups without config discipline
- Users expect instant responses (add queue monitoring)
- Session state matters across Gateway restarts (implement persistence checks)
Security reminder: As noted in security analysis, OpenClaw stores session transcripts and credentials locally. Treat your ~/.openclaw directory as sensitive — use encrypted drives and restrict file permissions.
अगर OpenClaw + Telegram आपको वहाँ पहुँचाता है जहाँ आपको जाना है, तो इसके साथ चलें। बस सेशन कुंजियों को साफ रखें और जानें कि कौन से समूहों को कौन सा एजेंट मिलता है।
Macaron में, हम वही रूटिंग चुनौतियों को स्वचालित रूप से संभालते हैं — प्लेटफॉर्म्स के बीच सेशन अलगाव, जब आप चैनल जोड़ते हैं तो कोई मैनुअल कॉन्फ़िग पैचिंग नहीं। अगर आप बिना हर बार कॉन्फ़िग्स को पुनर्निर्माण किए मल्टी-प्लेटफॉर्म रूटिंग का परीक्षण करना चाहते हैं, इसे एक वास्तविक वर्कफ़्लो के साथ आज़माएँ और देखें यह आपके सेटअप को कैसे संभालता है।
सामान्य प्रश्न
प्रश्न: मेरा बॉट समूह संदेशों का बिल्कुल भी जवाब नहीं दे रहा। मुझे पहले कहाँ जाँच करनी चाहिए? BotFather प्राइवेसी सेटिंग्स। अगर यह ON पर सेट है, तो बॉट केवल सीधे @mentions देखता है — बाकी सब कुछ चुपचाप छोड़ दिया जाता है। BotFather → /mybots → Bot Settings → Group Privacy → इसे OFF पर कर दें। यह समूह सेटअप के लिए सबसे सामान्य "यह क्यों काम नहीं कर रहा" होता है।
प्रश्न: मैं अपने समूह का चैट ID कैसे ढूँढूँ? बॉट को समूह में जोड़ें, कोई भी संदेश भेजें, फिर openclaw logs --follow चलाएँ। इनकमिंग अपडेट में chat.id दिखाई देगा — समूहों के लिए यह एक नकारात्मक संख्या होगी। यही वह मूल्य है जिसे आप अपनी व्हाइटलिस्ट कॉन्फ़िग में डालते हैं।
प्रश्न: क्या मुझे प्रत्येक Telegram खाते के लिए एक अलग बॉट टोकन की आवश्यकता है जिसे मैं रूट कर रहा हूँ? हाँ। channels.telegram.accounts[] में प्रत्येक प्रविष्टि को अपना BotFather टोकन चाहिए। एक टोकन, एक बॉट पहचान। अगर आप कई बॉट चला रहे हैं और चीजें आपस में मिल रही हैं, तो OpenClaw गेटवे कॉन्फ़िग संदर्भ यह बताता है कि खाता-स्तरीय रूटिंग अलगाव वास्तव में कैसे काम करता है।
प्रश्न: फोरम विषय — क्या मुझे प्रत्येक को मैन्युअली कॉन्फ़िगर करना होगा? केवल तभी जब आप प्रति-विषय सिस्टम प्रॉम्प्ट चाहते हैं। OpenClaw सत्र कुंजी अलगाव को स्वचालित रूप से संभालता है (:topic:<threadId> प्रत्यय), इसलिए बातचीत बिना किसी कॉन्फ़िगरेशन के अलग रहती है। मैन्युअल सेटअप की आवश्यकता केवल तब होती है जब आप प्रति विषय भिन्न एजेंट व्यवहार चाहते हैं।
प्रश्न: गेटवे पुनरारंभ के बाद सत्र संदर्भ खो देते हैं। क्या यह अपेक्षित है? डिफ़ॉल्ट रूप से, हाँ — सत्र स्थिति पुनरारंभ के बाद जारी नहीं रहती जब तक कि आपने स्थायित्व को कॉन्फ़िगर नहीं किया हो। यदि यह आपके उपयोग के मामले के लिए समस्या है, तो गेटवे स्तर पर उपलब्ध स्थायित्व विकल्पों के लिए OpenClaw त्वरित प्रारंभ मार्गदर्शिका देखें।
प्रश्न: मैं इसे VPS पर सेट कर रहा हूँ। क्या कुछ टेलीग्राम-विशेष मुझे जानना चाहिए? सुनिश्चित करें कि आपके सर्वर की आउटबाउंड कनेक्शंस api.telegram.org पर अवरुद्ध नहीं हैं — कुछ सस्ते VPS प्रदाता इसे प्रतिबंधित करते हैं। इसके अलावा, सामान्य सुरक्षा उपाय लागू होते हैं: नॉन-रूट निष्पादन, फ़ायरवॉल नियम, एनव वेरिएबल्स में टोकन हार्डकोड नहीं। यदि आप शुरुआत से शुरू कर रहे हैं तो OpenClaw VPS परिनियोजन मार्गदर्शिका पूरी सेटअप को कवर करती है।
प्रश्न: मैंने टेलीग्राम के लिए Moltbot चलाया था। क्या माइग्रेशन सरल है? अधिकांशतः हाँ, लेकिन कॉन्फ़िगरेशन संरचना बदल गई है। यदि स्विचिंग के बाद संघर्ष या अप्रत्याशित व्यवहार हो तो Moltbot टेलीग्राम सेटअप तुलना देखना सार्थक है — यह दर्शाता है कि दोनों के बीच क्या बदला।










