Routing
Routing determines which agent handles each message based on channel, account, peer, and guild. OpenClaw supports complex routing rules for multi-agent setups, group policies, and access control.What is Routing?
Routing maps incoming messages to agents and sessions:- Extract identifiers from inbound message (channel, account, peer)
- Match routing bindings against message context
- Select agent based on match or default
- Build session key for agent + routing context
- Load/create session and deliver message
Routing Basics
Default Routing
Without routing configuration, all messages go to the default agent:agent:main.
Location: src/routing/resolve-route.ts:438
Simple Multi-Agent Routing
Route different channels to different agents:- Telegram messages →
mainagent (default) - Discord messages →
codingagent
Routing Bindings
Binding Structure
Routing bindings map message patterns to agents:Binding Priority
Bindings are evaluated in order of specificity:- Peer match (specific user/group)
- Parent peer match (thread inherits from parent)
- Guild + roles (Discord server + member roles)
- Guild (Discord server)
- Team (Slack workspace)
- Account (specific account)
- Channel (messaging platform)
- Default (fallback)
More specific bindings take precedence over generic ones.
Routing Examples
Route by Channel
Route by Account
Route by Peer (User/Group)
Route by Guild (Discord)
Route by Roles (Discord)
admin OR moderator role route to admin-agent.
Location: src/routing/resolve-route.ts:284
Wildcard Account Routing
Routing Flow
Complete Routing Flow
Routing Decision Tree
Location: src/routing/resolve-route.ts:418Allowlists (Access Control)
Channel Allowlists
Control who can message through each channel:- Wildcard
*: Allow everyone - User ID:
123456789 - Username:
user:aliceor@alice - Phone:
+15551234567 - Guild:
guild:123456789
Account-Specific Allowlists
Nested Allowlists
Channel and account allowlists combine:- Check channel allowlist (must include “admin” OR account has wildcard)
- Check account allowlist (must match or be wildcard)
Group Policies
Group Policy Types
Default:
open
Location: src/config/types.base.ts:8
Group Access Control Flow
Location: src/web/inbound/access-control.ts:82Mention Gating
In group chats, require mentions to respond:- Discord:
@bot-name - Telegram:
@bot_username - Slack:
@bot-name - WhatsApp: Quote/reply to bot
Group vs DM Routing
Route DMs and groups to different agents:DM-Only Mode
Ignore all group messages:Multi-Agent Routing Table
Complex Routing Example
Location: src/routing/resolve-route.ts:295
Routing Testing
Test Routing Rules
Debug Routing
Enable verbose routing logs:Advanced Routing
Thread Routing
Threads inherit routing from parent:987654321 route to support agent.
Location: src/routing/resolve-route.ts:356
Session Key Building
Routing builds session keys:Identity Resolution
Identity links affect session keys:Configuration Examples
Personal + Work Split
Multi-Channel Support Setup
Admin + Community Agents
admin agent, others to community.
Troubleshooting
Messages Route to Wrong Agent
Allowlist Not Working
Group Messages Ignored
Next Steps
Agent Configuration
Configure multiple agents with different models
Session Management
Understand session keys and scoping
Channel Setup
Configure channels and access control
Access Control
Advanced allowlist and pairing configuration

