
مرحبًا بمطوري الأتمتة — إذا كنت تقوم بتوصيل OpenClaw بتليجرام وتتساءل عن كيفية عمل التوجيه فعليًا عندما تبدأ الرسائل في التدفق من الرسائل المباشرة، المجموعات، والمواضيع، فابق هنا.
قضيت الأسبوعين الماضيين في تشغيل OpenClaw من خلال تليجرام في ثلاث إعدادات مختلفة: الرسائل المباشرة الشخصية، مجموعات الفريق، ومواضيع المنتدى. ليست سيناريوهات تجريبية. اختبارات توجيه حقيقية حيث قمت بتعمد كسر عزل الجلسات، إغراقه بالطلبات المتزامنة، ومراقبة كيفية تعامل البوابة مع تكوينات الحسابات المتعددة.
السؤال الذي كنت أعود إليه مرارًا: هل يمكن لهذا أن يحافظ فعليًا على حدود جلسة نظيفة عندما تتعامل مع محادثات متعددة، أم أن الأمر ينهار كله في سلسلة محادثات فوضوية؟
إليك ما وجدته، بالإضافة إلى أنماط التكوين الدقيقة التي نجت.
للسياق، OpenClaw (المعروف سابقًا باسم Moltbot وClawdbot) حصل على أكثر من 100,000 نجمة على GitHub في أوائل عام 2026 كمساعد ذكي مفتوح المصدر. تم إنشاؤه بواسطة بيتر ستينبرجر، وهو يربط منصات المراسلة مثل تليجرام بوكلاء الذكاء الاصطناعي الذين يعملون محليًا أو على خوادم خاصة.

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:

/start to see available commands/newbot
bot (e.g., YourProjectBot)123456789:ABCdefGHIjklMNOpqrsTUVwxyz/revoke in BotFather to generate a new oneCritical 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.
Getting the token into OpenClaw is where most setup guides stop — but that's where real testing should start.
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"
}
}
}
Here's the sequence I run every time to confirm the Gateway actually sees Telegram updates:
openclaw gateway --log-level debug
/start to your bot in Telegram
dmPolicy: "pairing"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.
Security note: For production deployments, consider using DigitalOcean's hardened OpenClaw image which includes firewall rules, container isolation, and non-root execution by default.

OpenClaw's command system is where routing logic starts to matter. The Gateway recognizes slash commands across all channels, but Telegram adds its own command autocomplete layer.
The official OpenClaw repository documents the full command set, but after real-world testing, only a handful prove essential.
These are the commands I actually use in production setups (not the full list — just what survives real usage):
Important: /activation always only affects the current session. To persist it, add it to your config's requireMention settings.
This is what makes your bot feel native in Telegram:
/mybots → Select your bot → Edit Commandsnew - Start fresh sessionstatus - Check session statehelp - Show all commands
/ autocomplete menuReality 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.

This is where OpenClaw's session architecture either makes sense or falls apart. Session keys determine whether conversations stay isolated or bleed together.
OpenClaw generates session keys using this pattern:
agent:<agentId>:telegram:<chatType>:<chatId>[:topic:<topicId>]
Breakdown:
main sessiontelegram:group:<chatId>):topic:<threadId> suffix)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.
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).

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.
When messages disappear into the void, it's usually one of these three culprits.
/mybots → Your Bot → Bot Settings → Group Privacy → OFF
openclaw logs --follow | grep "skipping group message"
channels.telegram.groups is defined, unlisted groups are ignored.openclaw logs --level debug --filter telegram
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.
After two weeks of daily use across three different Telegram setups, here's what survived:
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "env:TELEGRAM_BOT_TOKEN",
"dmPolicy": "pairing",
"groups": {
"*": { "requireMention": true }
}
}
}
}
Why this works:
/new, /status, /help — Users forget themOpenClaw Telegram routing is solid for:
It gets messy when:
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. إذا كان مضبوطًا على التشغيل، فإن البوت يرى فقط الإشارات المباشرة @mentions — كل شيء آخر يُسقط بصمت. انتقل إلى BotFather → /mybots → إعدادات البوت → خصوصية المجموعة → إيقاف تشغيلها. هذا هو السبب الأكثر شيوعًا لعدم عمله في إعدادات المجموعة.
س: كيف يمكنني العثور على معرف الدردشة لمجموعتي؟ أضف البوت إلى المجموعة، أرسل أي رسالة، ثم قم بتشغيل openclaw logs --follow. يظهر chat.id في التحديث الوارد — سيكون رقمًا سالبًا للمجموعات. هذا هو القيمة التي تضعها في تكوين القائمة البيضاء.
س: هل أحتاج إلى رمز بوت منفصل لكل حساب Telegram أقوم بتوجيهه؟ نعم. كل إدخال في channels.telegram.accounts[] يحتاج إلى رمز BotFather خاص به. رمز واحد، هوية بوت واحدة. إذا كنت تُشغل بوتات متعددة وتختلط الأمور، فإن مرجع تكوين بوابة OpenClaw يوضح كيفية عمل العزل على مستوى الحساب.
س: مواضيع المنتدى — هل أحتاج إلى تكوين كل منها يدويًا؟ فقط إذا كنت تريد مطالبات نظام لكل موضوع. يتولى OpenClaw عزل مفتاح الجلسة تلقائيًا (اللاحقة :topic:<threadId>)، لذا تبقى المحادثات منفصلة دون أي تكوين. الإعداد اليدوي مطلوب فقط عندما ترغب في سلوك مختلف للوكيل لكل موضوع.
س: الجلسات تفقد السياق بعد إعادة تشغيل البوابة. هل هذا متوقع؟ بشكل افتراضي، نعم — حالة الجلسة لا تستمر عبر إعادة التشغيل إلا إذا قمت بتكوين الاستمرارية. إذا كان ذلك يمثل مشكلة بالنسبة لحالتك، تحقق من دليل بدء التشغيل السريع لـ OpenClaw للحصول على خيارات الاستمرارية المتاحة على مستوى البوابة.
س: أنا أقوم بإعداد هذا على VPS. هل هناك شيء محدد بخصوص Telegram يجب أن أعرفه؟ تأكد من أن اتصالات الخروج من خادمك إلى api.telegram.org ليست محظورة — بعض موفري VPS الرخيصة يقيدون ذلك. بخلاف ذلك، ينطبق التشديد المعتاد: التنفيذ بدون جذر، قواعد الجدار الناري، الرمز المميز في متغيرات البيئة وليس مشفرًا. يغطي دليل نشر OpenClaw على VPS الإعداد الكامل إذا كنت تبدأ من الصفر.
س: كنت أدير Moltbot لـ Telegram. هل الانتقال بسيط؟ في الغالب نعم، لكن بنية التكوين تغيرت. إذا واجهت تعارضات أو سلوك غير متوقع بعد التبديل، فإن مقارنة إعداد Moltbot على Telegram تستحق المراجعة — فهي توضح ما تغير بين الاثنين.