Prerequisites
- A running OpenClaw gateway (see VPS Deploy Recipe)
- Relevant Bot tokens for the platforms you want to connect (e.g., Discord Bot Token, Telegram Bot API Token)
How OpenClaw Routing Works
OpenClaw uses an AGENTS.md file or a standard JSON config to define how incoming
messages from channels are handled. Every incoming message has a source (e.g.,
telegram, discord) and a context_id (usually the chat ID or
user ID).
Step 1 — Configure API Tokens
Add the tokens for your desired platforms to your secrets.env.
# Telegram
TELEGRAM_BOT_TOKEN=123456789:ABCdefGHIjklMNOpqrSTUvwxYZ
# Discord
DISCORD_BOT_TOKEN=MTA... (your long token)
# Slack
SLACK_BOT_TOKEN=xoxb-your-slack-token
SLACK_SIGNING_SECRET=your-slack-signing-secret
Step 2 — Define the Routing Config
Create or edit the openclaw.json file in your config directory. Here's a multi-channel
example that maps different platforms to specific agent configurations.
{
"channels": {
"telegram": {
"enabled": true,
"mode": "polling"
},
"discord": {
"enabled": true,
"mode": "websocket"
},
"slack": {
"enabled": true,
"mode": "socket_mode"
}
},
"routes": [
{
"source": "telegram",
"agent": "personal_assistant"
},
{
"source": "discord",
"agent": "community_mod"
},
{
"source": "slack",
"agent": "devops_bot"
}
]
}
Step 3 — Creating Specialized Agents (Optional)
In the routing configuration above, we referenced three different agents. You can define these agents
in your AGENTS.md or separate identity files (like SOUL.md).
# personal_assistant
You are my personal assistant on Telegram. Keep responses short and casual.
# community_mod
You are the moderator for our Discord server. Issue warnings to rule-breakers.
# devops_bot
You are a DevOps assistant on Slack. You have permission to read server logs.
Step 4 — Shared Memory Across Channels (Advanced)
If you want the same agent to remember you regardless of whether you message it on Telegram
or Discord, you can consolidate the context_id.
Currently, OpenClaw isolates sessions based on provider_id + chat_id. To
unify them, you would map both your Telegram User ID and Discord User ID to a single identity in
your configuration, though this requires a custom plugin or writing a routing script depending on
your OpenClaw version.
Step 5 — Apply Changes
Restart your OpenClaw gateway to apply the new tokens and routing rules.
systemctl --user restart openclaw-gateway
journalctl --user -u openclaw-gateway -f
Check the logs to ensure the gateway successfully connects to Discord (via WebSocket) and Telegram (via polling).
Related
- Connect to Feishu — set up a webhook-based channel
- Multi-Agent Config Template — a complete starter config