OpenClawSkills
GitHub
コア概念 • 5分で読める

チャンネルルーティング

WhatsApp / Telegram / Discord / Slack などのルーティング規則と共有コンテキスト。

OpenClaw は返信を決定論的に「メッセージが来たチャンネル」にルーティングします。モデルはチャンネルを選択しません。ルーティングはホスト設定によって制御され、予測可能です。

Tutorial.step

主要な用語

- ''Channel'':''whatsapp''、''telegram''、''discord''、''slack''、''signal''、''imessage''、''webchat''。

- AccountId:チャンネルごとのアカウントインスタンス(サポートされている場合)。

- AgentId:分離されたワークスペース + セッションストア(「脳」)。

- SessionKey:コンテキストを保存し、並行性を制御するために使用されるバケットキー。

Tutorial.step

Session key の形状(例)

ダイレクトメッセージはエージェントの main セッションに折りたたまれます:

- ''agent:<agentId>:<mainKey>'' (default: ''agent:main:main'')

グループとチャンネルはチャンネルごとに分離されています:

- Groups: ''agent:<agentId>:<channel>:group:<id>''

- Channels/rooms: ''agent:<agentId>:<channel>:channel:<id>''

スレッド:

- Slack/Discord threads append '':thread:<threadId>'' to the base key.

- Telegram forum topics embed '':topic:<topicId>'' in the group key.

Examples: ''agent:main:telegram:group:-1001234567890:topic:42'', ''agent:main:discord:channel:123456:thread:987654''

Tutorial.step

ルーティングルール(エージェントの選択方法)

ルーティングは各着信メッセージに対して1つのエージェントを選択します:

1. ''正確な peer マッチ''(''bindings'' に ''peer.kind'' + ''peer.id'' がある)。

2. ''Guild マッチ''(Discord)''guildId'' 経由。

3. ''Team マッチ''(Slack)''teamId'' 経由。

4. ''Account マッチ''(チャンネルの ''accountId'')。

5. Channel マッチ(そのチャンネルの任意のアカウント)。

6. ''デフォルトエージェント''(''agents.list[].default''、なければリストの最初のエントリ、フォールバックは ''main'')。

マッチしたエージェントがどのワークスペースとセッションストアを使用するかを決定します。

Tutorial.step

Broadcast groups(複数のエージェントを実行)

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:

Json5
{
  broadcast: {
    strategy: "parallel",
    "[email protected]": ["alfred", "baerbel"],
    "+15555550123": ["support", "logger"]
  }
}

See: ''/broadcast-groups''

Tutorial.step

設定の概要

- ''agents.list'':名前付きエージェント定義(ワークスペース、モデルなど)。

- ''bindings'':着信チャンネル/アカウント/peer をエージェントにマッピングします。

Example:

Json5
{
  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" }
  ]
}
Tutorial.step

Session ストレージ

Session ストアはステートディレクトリの下にあります(デフォルト ''~/.openclaw''):

- ''~/.openclaw/agents/<agentId>/sessions/sessions.json''

- JSONL トランスクリプトはストアと同じ場所にあります

''session.store'' と ''{agentId}'' テンプレートを使用して、ストアパスを上書きできます。

Tutorial.step

WebChat の動作

WebChat attaches to the selected agent and defaults to the agent's main session. Because of this, WebChat lets you see cross-channel context for that agent in one place.

Tutorial.step

返信コンテキスト(Reply context)

着信返信には以下が含まれます:

- ''ReplyToId''、''ReplyToBody''、''ReplyToSender''(利用可能な場合)。

- 引用されたコンテキストは ''[Replying to ...]'' ブロックとして ''[Replying to ...]'' に追加されます。

これはすべてのチャンネルで一貫しています。