
Hola creadores de automatización — si estás conectando OpenClaw a Telegram y te preguntas cómo funciona realmente el enrutamiento cuando los mensajes empiezan a llegar de DMs, grupos y temas, quédate por aquí.
Pasé las últimas dos semanas ejecutando OpenClaw a través de Telegram en tres configuraciones diferentes: DMs personales, grupos de equipo y temas de foro. No eran escenarios de demostración. Pruebas reales de enrutamiento donde deliberadamente rompí el aislamiento de sesiones, lo inundé con solicitudes concurrentes y observé cómo el Gateway manejaba configuraciones de múltiples cuentas.
La pregunta que me seguía haciendo era: ¿Puede realmente mantener límites de sesión limpios cuando estás manejando múltiples chats, o todo se colapsa en un hilo de conversación desordenado?
Esto es lo que encontré, además de los patrones de configuración exactos que sobrevivieron.
Para contexto, OpenClaw (anteriormente Moltbot y Clawdbot) ganó más de 100,000 estrellas en GitHub a principios de 2026 como un asistente de IA autónomo de código abierto. Creado por Peter Steinberger, conecta plataformas de mensajería como Telegram con agentes de IA que funcionan localmente o en servidores privados.

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.
Si OpenClaw + Telegram te lleva a donde necesitas ir, sigue adelante. Solo mantén las claves de sesión limpias y sabe qué grupos reciben qué agente.
En Macaron, manejamos los mismos desafíos de enrutamiento automáticamente: aislamiento de sesiones a través de plataformas, sin necesidad de parchar configuraciones manualmente cuando agregas canales. Si deseas probar el enrutamiento multiplataforma sin reconstruir configuraciones cada vez que escales, pruébalo con un flujo de trabajo real y ve cómo maneja tu configuración.
Preguntas Frecuentes
P: Mi bot no responde a los mensajes de grupo en absoluto. ¿Dónde debo revisar primero? Configuraciones de privacidad de BotFather. Si está activado, el bot solo ve menciones directas @ — todo lo demás se descarta silenciosamente. Ve a BotFather → /mybots → Configuración del Bot → Privacidad de Grupo → desactívalo. Esta es la razón más común de "por qué no funciona" para configuraciones de grupo.
P: ¿Cómo encuentro el ID de chat de mi grupo? Agrega el bot al grupo, envía cualquier mensaje y luego ejecuta openclaw logs --follow. El chat.id aparece en la actualización entrante — será un número negativo para los grupos. Ese es el valor que pones en tu configuración de lista blanca.
P: ¿Necesito un token de bot separado para cada cuenta de Telegram que estoy enroutando? Sí. Cada entrada en channels.telegram.accounts[] necesita su propio token de BotFather. Un token, una identidad de bot. Si estás ejecutando varios bots y las cosas se están mezclando, la referencia de configuración de la puerta de enlace OpenClaw desglosa cómo funciona realmente el aislamiento de enrutamiento a nivel de cuenta.
P: Temas del foro — ¿necesito configurar cada uno manualmente? Solo si deseas indicaciones del sistema por tema. OpenClaw maneja automáticamente el aislamiento de claves de sesión (:topic:<threadId> sufijo), por lo que las conversaciones se mantienen separadas sin ninguna configuración. La configuración manual solo es necesaria cuando deseas un comportamiento diferente del agente por tema.
P: Las sesiones siguen perdiendo contexto después de reiniciar Gateway. ¿Es eso esperado? Por defecto, sí — el estado de la sesión no persiste tras los reinicios a menos que hayas configurado la persistencia. Si eso es un obstáculo para tu caso de uso, consulta la guía de inicio rápido de OpenClaw para conocer las opciones de persistencia disponibles a nivel de Gateway.
P: Estoy configurando esto en un VPS. ¿Algo específico de Telegram que deba saber? Asegúrate de que las conexiones salientes de tu servidor a api.telegram.org no estén bloqueadas — algunos proveedores de VPS baratos restringen esto. Además de eso, se aplican las medidas habituales de seguridad: ejecución sin privilegios de root, reglas de firewall, token en variables de entorno y no codificado. La guía de despliegue de OpenClaw en VPS cubre toda la configuración si estás empezando desde cero.
P: Solía ejecutar Moltbot para Telegram. ¿Es sencilla la migración? En su mayoría sí, pero la estructura de configuración cambió. Si encuentras conflictos o un comportamiento inesperado después de cambiar, vale la pena revisar la comparación de configuración de Moltbot para Telegram — detalla lo que cambió entre los dos.