
Ciao costruttori di automazioni — se stai collegando OpenClaw a Telegram e ti chiedi come funziona il routing quando i messaggi iniziano ad arrivare da DM, gruppi e argomenti, resta sintonizzato.
Ho passato le ultime due settimane a testare OpenClaw su Telegram in tre configurazioni diverse: DM personali, gruppi di lavoro e argomenti nei forum. Non scenari dimostrativi. Veri test di routing dove ho deliberatamente infranto l'isolamento delle sessioni, l'ho inondato di richieste simultanee e ho osservato come il Gateway gestiva le configurazioni multi-account.
La domanda che continuavo a pormi era: Può effettivamente mantenere confini di sessione puliti quando si gestiscono più chat, o tutto si trasforma in un unico disordinato thread di conversazione?
Ecco cosa ho scoperto, oltre ai modelli di configurazione esatti che hanno resistito.
Per contesto, OpenClaw (precedentemente noto come Moltbot e Clawdbot) ha guadagnato oltre 100.000 stelle su GitHub all'inizio del 2026 come assistente AI autonomo open-source. Creato da Peter Steinberger, connette piattaforme di messaggistica come Telegram ad agenti AI che funzionano localmente o su server privati.

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.
Se OpenClaw + Telegram ti porta dove devi andare, vai avanti. Tieni solo pulite le chiavi di sessione e sappi quali gruppi ricevono quale agente.
Da Macaron, gestiamo automaticamente le stesse sfide di routing — isolamento delle sessioni su tutte le piattaforme, senza bisogno di modifiche manuali alla configurazione quando aggiungi canali. Se vuoi testare il routing multipiattaforma senza dover ricostruire le configurazioni ogni volta che aumenti la scala, provalo con un vero flusso di lavoro e vedi come gestisce il tuo setup.
FAQ
D: Il mio bot non risponde affatto ai messaggi di gruppo. Dove devo controllare prima? Impostazioni della privacy di BotFather. Se è impostato su ON, il bot vede solo le menzioni dirette @ — tutto il resto viene ignorato silenziosamente. Vai su BotFather → /mybots → Impostazioni Bot → Privacy di Gruppo → disattivalo. Questo è il motivo più comune per cui "non funziona" per le configurazioni di gruppo.
D: Come posso trovare l'ID chat del mio gruppo? Aggiungi il bot al gruppo, invia un qualsiasi messaggio, poi esegui openclaw logs --follow. L'chat.id apparirà nell'aggiornamento in arrivo — sarà un numero negativo per i gruppi. Questo è il valore che metti nella tua configurazione whitelist.
D: Ho bisogno di un token bot separato per ogni account Telegram che sto instradando? Sì. Ogni voce in channels.telegram.accounts[] ha bisogno del suo token BotFather. Un token, un'identità bot. Se stai gestendo più bot e le cose si stanno confondendo, la riferimento alla configurazione del gateway OpenClaw spiega come funziona effettivamente l'isolamento del routing a livello di account.
D: Argomenti del forum — devo configurare manualmente ciascuno? Solo se desideri prompt di sistema per argomento. OpenClaw gestisce automaticamente l'isolamento della chiave di sessione (suffisso :topic:<threadId>), quindi le conversazioni restano separate senza nessuna configurazione. L'impostazione manuale è necessaria solo se vuoi un comportamento diverso dell'agente per ogni argomento.
D: Le sessioni perdono contesto dopo i riavvii del Gateway. È normale? Di default, sì — lo stato della sessione non si conserva dopo i riavvii a meno che non sia stata configurata la persistenza. Se questo è un problema per il tuo caso d'uso, consulta la guida rapida di OpenClaw per le opzioni di persistenza disponibili a livello di Gateway.
D: Sto configurando questo su un VPS. C'è qualcosa di specifico su Telegram che dovrei sapere? Assicurati che le connessioni in uscita del tuo server verso api.telegram.org non siano bloccate — alcuni provider di VPS economici lo limitano. Oltre a ciò, si applicano le solite misure di sicurezza: esecuzione non come root, regole del firewall, token in variabili d'ambiente e non codificato. La guida di distribuzione OpenClaw su VPS copre l'intera configurazione se parti da zero.
D: Ho usato Moltbot per Telegram. La migrazione è semplice? Per lo più sì, ma la struttura di configurazione è cambiata. Se incontri conflitti o comportamenti inattesi dopo il passaggio, il confronto delle configurazioni di Moltbot per Telegram è utile — mappa cosa è cambiato tra i due.