{ "title": "Channels & routing", "content": "OpenClaw routes replies **back to the channel where a message came from**. The\nmodel does not choose a channel; routing is deterministic and controlled by the\nhost configuration.\n\n* **Channel**: `whatsapp`, `telegram`, `discord`, `slack`, `signal`, `imessage`, `webchat`.\n* **AccountId**: per‑channel account instance (when supported).\n* **AgentId**: an isolated workspace + session store (“brain”).\n* **SessionKey**: the bucket key used to store context and control concurrency.\n\n## Session key shapes (examples)\n\nDirect messages collapse to the agent’s **main** session:\n\n* `agent::` (default: `agent:main:main`)\n\nGroups and channels remain isolated per channel:\n\n* Groups: `agent:::group:`\n* Channels/rooms: `agent:::channel:`\n\n* Slack/Discord threads append `:thread:` to the base key.\n* Telegram forum topics embed `:topic:` in the group key.\n\n* `agent:main:telegram:group:-1001234567890:topic:42`\n* `agent:main:discord:channel:123456:thread:987654`\n\n## Routing rules (how an agent is chosen)\n\nRouting picks **one agent** for each inbound message:\n\n1. **Exact peer match** (`bindings` with `peer.kind` + `peer.id`).\n2. **Guild match** (Discord) via `guildId`.\n3. **Team match** (Slack) via `teamId`.\n4. **Account match** (`accountId` on the channel).\n5. **Channel match** (any account on that channel).\n6. **Default agent** (`agents.list[].default`, else first list entry, fallback to `main`).\n\nThe matched agent determines which workspace and session store are used.\n\n## Broadcast groups (run multiple agents)\n\nBroadcast groups let you run **multiple agents** for the same peer **when OpenClaw would normally reply** (for example: in WhatsApp groups, after mention/activation gating).\n\nSee: [Broadcast Groups](/broadcast-groups).\n\n* `agents.list`: named agent definitions (workspace, model, etc.).\n* `bindings`: map inbound channels/accounts/peers to agents.\n\nSession stores live under the state directory (default `~/.openclaw`):\n\n* `~/.openclaw/agents//sessions/sessions.json`\n* JSONL transcripts live alongside the store\n\nYou can override the store path via `session.store` and `{agentId}` templating.\n\nWebChat attaches to the **selected agent** and defaults to the agent’s main\nsession. Because of this, WebChat lets you see cross‑channel context for that\nagent in one place.\n\nInbound replies include:\n\n* `ReplyToId`, `ReplyToBody`, and `ReplyToSender` when available.\n* Quoted context is appended to `Body` as a `[Replying to ...]` block.\n\nThis is consistent across channels.", "code_samples": [ { "code": "See: [Broadcast Groups](/broadcast-groups).\n\n## Config overview\n\n* `agents.list`: named agent definitions (workspace, model, etc.).\n* `bindings`: map inbound channels/accounts/peers to agents.\n\nExample:", "language": "unknown" } ], "headings": [ { "level": "h2", "text": "Key terms", "id": "key-terms" }, { "level": "h2", "text": "Session key shapes (examples)", "id": "session-key-shapes-(examples)" }, { "level": "h2", "text": "Routing rules (how an agent is chosen)", "id": "routing-rules-(how-an-agent-is-chosen)" }, { "level": "h2", "text": "Broadcast groups (run multiple agents)", "id": "broadcast-groups-(run-multiple-agents)" }, { "level": "h2", "text": "Config overview", "id": "config-overview" }, { "level": "h2", "text": "Session storage", "id": "session-storage" }, { "level": "h2", "text": "WebChat behavior", "id": "webchat-behavior" }, { "level": "h2", "text": "Reply context", "id": "reply-context" } ], "url": "llms-txt#channels-&-routing", "links": [] }