通过 bot token + WebSocket 事件接入自托管 Mattermost。支持频道、群组和私信。

安装

openclaw plugins install @openclaw/mattermost

最小配置

{
  channels: {
    mattermost: {
      enabled: true,
      botToken: "mm-token",
      baseUrl: "https://chat.example.com",
      dmPolicy: "pairing",
    },
  },
}

环境变量(默认账号)

  • MATTERMOST_BOT_TOKEN
  • MATTERMOST_URL

Chat 模式

  • oncall(默认):仅在频道中被 @mention 时回复
  • onmessage:回复所有频道消息
  • onchar:消息以触发前缀开头时回复
{
  channels: {
    mattermost: {
      chatmode: "onchar",
      oncharPrefixes: [">", "!"],
    },
  },
}

线程与会话

replyToMode 控制回复是否在线程中:

  • off(默认):仅当入站消息已在线程中时才在线程回复
  • first / all:为顶层消息创建线程

访问控制

DM:dmPolicy: "pairing"(默认),通过 openclaw pairing approve mattermost <CODE> 审批

频道(群组):groupPolicy: "allowlist"(默认),通过 groupAllowFrom 配置白名单

{
  channels: {
    mattermost: {
      groupPolicy: "open",
      groups: {
        "*": { requireMention: true },
        "team-channel-id": { requireMention: false },
      },
    },
  },
}

原生 Slash 命令

{
  channels: {
    mattermost: {
      commands: {
        native: true,
        callbackUrl: "https://gateway.example.com/api/channels/mattermost/command",
      },
    },
  },
}

回调 URL 必须从 Mattermost 服务器可达。

流式预览

{
  channels: {
    mattermost: {
      streaming: "partial",  // off | partial | block | progress
    },
  },
}

交互按钮

{
  channels: {
    mattermost: {
      capabilities: ["inlineButtons"],
    },
  },
}

按钮点击通过 HMAC-SHA256 验证,action id 必须为纯字母数字(不含连字符/下划线)。

多账号

{
  channels: {
    mattermost: {
      accounts: {
        default: { botToken: "mm-token", baseUrl: "https://chat.example.com" },
        alerts: { botToken: "mm-token-2", baseUrl: "https://alerts.example.com" },
      },
    },
  },
}

相关链接