Skip to main content

Channels & routing

OpenClaw routes replies back to the 渠道 where a message came from. The 模型 does not choose a 渠道; routing is deterministic and controlled by the host configuration.

Key terms

  • 渠道whatsapptelegramdiscordslacksignalimessagewebchat
  • AccountId: per‑渠道 account instance (when supported).
  • AgentId: an isolated workspace + 会话 store (“brain”).
  • SessionKey: the bucket key used to store context and control concurrency.

Session key shapes (examples)

Direct messages collapse to the agent’s main 会话:
  • agent:<agentId>:<mainKey>(默认:agent:main:main
Groups and channels remain isolated per 渠道:
  • 群组:agent:<agentId>:<channel>:group:<id>
  • 频道/房间:agent:<agentId>:<channel>:channel:<id>
Threads:
  • Slack/Discord 话题会在基础键后附加 :thread:<threadId>
  • Telegram 论坛主题会将 :topic:<topicId> 嵌入到群组键中。
Examples:
  • agent:main:telegram:group:-1001234567890:topic:42
  • agent:main:discord:channel:123456:thread:987654

Routing rules (how an agent is chosen)

Routing picks one agent for each inbound message:
  1. 精确对等匹配bindings 包含 peer.kind + peer.id)。
  2. 公会匹配(Discord)通过 guildId
  3. 团队匹配(Slack)通过 teamId
  4. 账户匹配(渠道上的 accountId)。
  5. Channel match (any account on that 渠道).
  6. 默认代理agents.list[].default,否则为列表第一项,回退到 main)。
The matched agent determines which workspace and 会话 store are used.

Broadcast groups (run multiple agents)

Broadcast groups let you run multiple agents for the same peer when OpenClaw would normally reply (for example: in WhatsApp groups, after mention/activation gating). Config:
{
  broadcast: {
    strategy: "parallel",
    "120363403215116621@g.us": ["alfred", "baerbel"],
    "+15555550123": ["support", "logger"],
  },
}
请参阅:广播组

Config overview

  • agents.list:命名的代理定义(工作区、模型等)。
  • bindings:将入站渠道/账户/对等端映射到代理。
示例:
{
  agents: {
    list: [{ id: "support", name: "Support", workspace: "~/.openclaw/workspace-support" }],
  },
  bindings: [
    { match: { channel: "slack", teamId: "T123" }, agentId: "support" },
    { match: { channel: "telegram", peer: { kind: "group", id: "-100123" } }, agentId: "support" },
  ],
}

会话存储

会话存储位于状态目录下(默认为 ~/.openclaw):
  • ~/.openclaw/agents/<agentId>/sessions/sessions.json
  • JSONL 记录与存储并存
您可以通过 session.store{agentId} 模板覆盖存储路径。

WebChat 行为

WebChat 附加到选定的代理,并默认为该代理的主会话。因此,WebChat 允许您在一个位置查看该代理的跨通道上下文。

回复上下文

入站回复包括:
  • ReplyToIdReplyToBodyReplyToSender(如果可用)。
  • 引用上下文作为 [Replying to ...] 块附加到 Body
这在所有通道中是一致的。
本页面源自 openclaw/openclaw,由 BeaversLab 翻译,遵循 MIT 协议 发布。
Last modified on March 27, 2026