OpenClaw 在各平台(Discord、iMessage、Matrix、Microsoft Teams、Signal、Slack、Telegram、WhatsApp、Zalo)中统一处理群组聊天。

核心概念

  • DM 访问:由 *.allowFrom 控制
  • 群组访问:由 *.groupPolicy + 白名单(*.groups、*.groupAllowFrom)控制
  • 回复触发:由 mention 门控(requireMention、/activation)控制

消息处理流程

groupPolicy? disabled -> 丢弃
groupPolicy? allowlist -> 群组被允许? no -> 丢弃
requireMention? yes -> 被 mention? no -> 仅存储为上下文
否则 -> 回复

可见回复

默认 messages.groupChat.visibleReplies: "message_tool",agent 的最终回答不自动发布到房间,需通过 message(action=send) 工具发送。

恢复自动回复:

{ messages: { groupChat: { visibleReplies: "automatic" } } }

群组策略

策略行为
"open"群组绕过白名单,mention 门控仍生效
"disabled"完全阻止所有群组消息
"allowlist"仅允许配置白名单中的群组/房间

各平台配置示例:

{
  channels: {
    whatsapp: { groupPolicy: "disabled", groupAllowFrom: ["+15551234567"] },
    telegram: { groupPolicy: "disabled", groupAllowFrom: ["123456789"] },
    signal: { groupPolicy: "disabled", groupAllowFrom: ["+15551234567"] },
    discord: { groupPolicy: "allowlist", guilds: { GUILD_ID: { channels: { help: { allow: true } } } } },
    slack: { groupPolicy: "allowlist", channels: { "#general": { allow: true } } },
  },
}

Mention 门控

群组消息默认需要 mention 才能触发回复:

{
  channels: {
    whatsapp: {
      groups: {
        "*": { requireMention: true },
        "123@g.us": { requireMention: false },
      },
    },
  },
  agents: {
    list: [{
      id: "main",
      groupChat: {
        mentionPatterns: ["@openclaw", "openclaw", "\\+15555550123"],
        historyLimit: 50,
      },
    }],
  },
}

群组工具限制

{
  channels: {
    telegram: {
      groups: {
        "*": { tools: { deny: ["exec"] } },
        "-1001234567890": {
          tools: { deny: ["exec", "read", "write"] },
          toolsBySender: {
            "id:123456789": { alsoAllow: ["exec"] },
          },
        },
      },
    },
  },
}

常用配置速查

目标配置
允许所有群组但仅 @mention 回复groups: { "*": { requireMention: true } }
禁用所有群组回复groupPolicy: "disabled"
仅特定群组groups: { "<group-id>": { ... } }
仅你能触发groupPolicy: "allowlist", groupAllowFrom: ["+1555..."]
跨频道复用白名单groupAllowFrom: ["accessGroup:operators"]

相关链接