群組
OpenClaw 會在各種平台上一致地處理群組聊天:WhatsApp、Telegram、Discord、Slack、Signal、iMessage、Microsoft Teams。新手入門(2 分鐘)
- OpenClaw「存在」於你自己的通訊帳號上。 沒有獨立的 WhatsApp 機器人使用者。 如果你在某個群組中,OpenClaw 就能看到該群組並在那裡回應。
- 預設行為:
- 群組是受限的(
groupPolicy: "allowlist")。 -
- 回覆需要被點名,除非你明確停用點名門檻。
TL;DR快速流程(群組訊息會發生什麼):
- 私訊(DM)存取 由
*.allowFrom控制。- 群組存取 由
*.groupPolicy+ 允許清單(*.groups、*.groupAllowFrom)控制。- 回覆觸發 由提及管控(
requireMention、/activation)控制。
| 目標 | 要設定的項目 |
|---|---|
| 允許所有群組,但只在 @mentions 時回覆 | groups: { "*": { requireMention: true } } |
| 停用所有群組回覆 | groupPolicy: "disabled" |
| 只允許特定群組 | groups: { "<group-id>": { ... } }(沒有 "*" 金鑰) |
| 只有你可以在群組中觸發 | groupPolicy: "allowlist"、groupAllowFrom: ["+1555..."] |
31. 工作階段金鑰
- 群組工作階段使用
agent:<agentId>:<channel>:group:<id>工作階段金鑰(房間/頻道使用agent:<agentId>:<channel>:channel:<id>)。 - Telegram 論壇主題會在群組 ID 上加入
:topic:<threadId>,讓每個主題都有自己的工作階段。 -
- 私聊使用主要工作階段(或依設定為每位寄件者一個)。
- 群組工作階段會略過心跳。
模式:個人私訊 + 公開群組(單一代理程式)
可以——如果你的「個人」流量是 私訊(DM),而「公開」流量是 群組,這個模式運作得很好。 原因:在單一代理模式下,DM 通常落在主要工作階段金鑰(agent:main:main),而群組一律使用非主要工作階段金鑰(agent:main:<channel>:group:<id>)。 34. 若啟用沙箱並設定 mode: "non-main",這些群組工作階段會在 Docker 中執行,而你的主要 DM 工作階段則留在主機上。
這樣你會有一個代理程式「大腦」(共享的工作區與記憶),但有兩種執行姿態:
- 私訊(DM):完整工具(主機)
- 群組:沙箱 + 受限工具(Docker)
如果你需要真正分離的工作區/角色(「個人」與「公開」絕不能混用),請使用第二個代理程式 + 綁定。請參閱 Multi-Agent Routing。 35. 請參閱 Multi-Agent Routing。範例(私訊在主機上、群組在沙箱中且僅有傳訊工具):
workspaceAccess: "none",並只將允許清單中的路徑掛載到沙箱中: 36. 保持 workspaceAccess: "none",並只將 allowlist 中的路徑掛載到沙箱中:
- 相關:
- 設定金鑰與預設值:Gateway configuration
- 偵錯工具為何被封鎖:Sandbox vs Tool Policy vs Elevated
- 綁定掛載細節:Sandboxing
顯示標籤
- UI 標籤在可用時使用
displayName,格式為<channel>:<token>。 #room保留給房間/頻道;群組聊天使用g-<slug>(小寫,空白轉為-,保留#@+._-)。
群組政策
控制各頻道中群組/房間訊息的處理方式:| 政策 | 行為 |
|---|---|
"open" | 群組略過允許清單;仍套用提及管控。 |
"disabled" | 完全封鎖所有群組訊息。 |
"allowlist" | 只允許符合設定之允許清單的群組/房間。 |
groupPolicy與提及管控是分開的(提及管控需要 @mentions)。- WhatsApp/Telegram/Signal/iMessage/Microsoft Teams:使用
groupAllowFrom(後備:明確的allowFrom)。 - Discord:允許清單使用
channels.discord.guilds.<id>.channels。 - Slack:允許清單使用
channels.slack.channels。 - Matrix:allowlist 使用
channels.matrix.groups(房間 ID、別名或名稱)。 Matrix:允許清單使用channels.matrix.groups(房間 ID、別名或名稱)。使用channels.matrix.groupAllowFrom來限制寄件者;也支援每個房間的users允許清單。 Matrix:允許清單使用channels.matrix.groups(房間 ID、別名或名稱)。使用channels.matrix.groupAllowFrom來限制寄件者;也支援每個房間的users允許清單。 - 群組私訊(Group DMs)是分開控制的(
channels.discord.dm.*、channels.slack.dm.*)。 - Telegram 允許清單可比對使用者 ID(
"123456789"、"telegram:123456789"、"tg:123456789")或使用者名稱("@alice"或"alice");前綴不分大小寫。 - 預設為
groupPolicy: "allowlist";如果你的群組允許清單是空的,群組訊息會被封鎖。
groupPolicy(開放/停用/允許清單)- 群組允許清單(
*.groups、*.groupAllowFrom、頻道專屬允許清單) - 提及管控(
requireMention、/activation)
39) 點名門檻(預設)
除非針對特定群組覆寫,否則群組訊息需要被提及。預設值位於各子系統的*.groups."*" 之下。 40. 預設值位於各子系統下的 *.groups."*"。
Replying to a bot message counts as an implicit mention (when the channel supports reply metadata). This applies to Telegram, WhatsApp, Slack, Discord, and Microsoft Teams.
mentionPatternsare case-insensitive regexes.- Surfaces that provide explicit mentions still pass; patterns are a fallback.
- 每個代理程式的覆寫:
agents.list[].groupChat.mentionPatterns(多個代理程式共用同一個群組時很有用)。 - Mention gating is only enforced when mention detection is possible (native mentions or
mentionPatternsare configured). - Discord 的預設值位於
channels.discord.guilds."*"(可依伺服器/頻道覆寫)。 - Group history context is wrapped uniformly across channels and is pending-only (messages skipped due to mention gating); use
messages.groupChat.historyLimitfor the global default andchannels.<channel>.historyLimit(或channels.<channel>.accounts.*.historyLimit)。設定0可停用。 Set0to disable. Set0to disable.
群組/頻道工具限制(選用)
部分頻道設定支援限制特定群組/房間/頻道內可用的工具。tools:整個群組允許/拒絕工具。toolsBySender:群組內依寄件者覆寫(鍵值為寄件者 ID/使用者名稱/電子郵件/電話號碼,視頻道而定)。使用"*"作為萬用字元。 Use"*"as a wildcard. Use"*"as a wildcard.
- 群組/頻道
toolsBySender比對 - 群組/頻道
tools - 預設(
"*")toolsBySender比對 - 預設(
"*")tools
- Group/channel tool restrictions are applied in addition to global/agent tool policy (deny still wins).
- 某些頻道對房間/頻道使用不同的巢狀結構(例如 Discord 的
guilds.*.channels.*、Slack 的channels.*、Microsoft Teams 的teams.*.channels.*)。
群組允許清單
當設定了channels.whatsapp.groups、channels.telegram.groups 或 channels.imessage.groups 時,這些金鑰會作為群組允許清單。使用 "*" 可以在仍設定預設提及行為的同時允許所有群組。 Use "*" to allow all groups while still setting default mention behavior. Use "*" to allow all groups while still setting default mention behavior.
Common intents (copy/paste):
- 停用所有群組回覆
- 只允許特定群組(WhatsApp)
- 允許所有群組,但需要提及(明確)
- 只有擁有者可以在群組中觸發(WhatsApp)
啟用(僅限擁有者)
群組擁有者可以切換每個群組的啟用狀態:/activation mention/activation always
channels.whatsapp.allowFrom 決定(未設定時使用機器人的自身 E.164)。請以單獨訊息送出指令。其他平台目前會忽略 /activation。 Send the command as a standalone message. Other surfaces currently ignore /activation.
情境欄位
群組的入站負載會設定:ChatType=groupGroupSubject(若已知)GroupMembers(若已知)WasMentioned(提及管控結果)- Telegram 論壇主題也會包含
MessageThreadId與IsForum。
\n sequences.
iMessage 特定事項
- 在路由或允許清單時,優先使用
chat_id:<id>。 - 列出聊天:
imsg chats --limit 20。 - 群組回覆一律回到相同的
chat_id。