OpenClawSkills
GitHub
通道 • 5 分钟阅读

Mattermost

Mattermost 机器人配置与 OpenClaw 接入方式

状态:通过插件支持(bot token + WebSocket 事件)。支持频道、群组与私信。

Mattermost 是可自托管的团队消息平台;产品与下载见 ''mattermost.com''。

Tutorial.step

需要安装插件

Mattermost 以插件形式提供,不随 core 安装打包。

通过 CLI 安装(npm registry):

Bash
openclaw plugins install @openclaw/mattermost

本地安装(当你从 git 仓库运行时):

Bash
openclaw plugins install ./extensions/mattermost

如果你在 configure/onboarding 里选择了 Mattermost,且检测到 git checkout,OpenClaw 会自动提示使用本地安装路径。

更多:''/plugin''

Tutorial.step

快速配置

1. 安装 Mattermost 插件。

2. 创建 Mattermost bot 账号并复制 bot token。

3. 复制 Mattermost base URL(例如 https://chat.example.com)。

4. 配置 OpenClaw 并启动 gateway。

最小配置:

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

环境变量(default account)

如果你更喜欢用 env vars,在 gateway 主机设置:

- MATTERMOST_BOT_TOKEN=...

- MATTERMOST_URL=https://chat.example.com

注意:环境变量只作用于 default 账号(default)。其他账号必须在配置文件中提供。

Tutorial.step

聊天模式(Chat modes)

Mattermost 默认会自动回复私信。频道内行为由 chatmode 控制:

- oncall(默认):仅在频道中被 @mention 时回复。

- onmessage:对频道里的每条消息都回复。

- onchar:当消息以某些触发前缀开头时回复。

示例:

Json5
{
  channels: {
    mattermost: {
      chatmode: "onchar",
      oncharPrefixes: [">", "!"],
    },
  },
}

说明:

- onchar 仍会对显式 @mention 做出回复。

- 旧配置中的 channels.mattermost.requireMention 仍被兼容,但推荐使用 chatmode。

Tutorial.step

访问控制(私信)

- 默认:channels.mattermost.dmPolicy = "pairing"(未知发送者会收到配对码)。

- 批准:

- openclaw pairing list mattermost

- openclaw pairing approve mattermost <CODE>

- 公开私信:channels.mattermost.dmPolicy="open" 且 channels.mattermost.allowFrom=["*"]。

Tutorial.step

频道/群组(groups)

- 默认:channels.mattermost.groupPolicy = "allowlist"(同时受 mention 门禁影响)。

- 用 channels.mattermost.groupAllowFrom 做发送者 allowlist(用户 id 或 @username)。

- 开放频道:channels.mattermost.groupPolicy="open"(仍受 mention 门禁影响)。

Tutorial.step

出站投递目标(targets)

在 openclaw message send 或 cron/webhooks 中使用:

- channel:<id>: Deliver to a channel

- user:<id>: Deliver to a DM

- @username:投递到私信(通过 Mattermost API 解析)

裸 id 会被当作 channel id。

Tutorial.step

多账号

在 channels.mattermost.accounts 下配置多个账号:

Json5
{
  channels: {
    mattermost: {
      accounts: {
        default: { name: "Primary", botToken: "mm-token", baseUrl: "https://chat.example.com" },
        alerts: { name: "Alerts", botToken: "mm-token-2", baseUrl: "https://alerts.example.com" },
      },
    },
  },
}
Tutorial.step

排障

- 频道里没回复:确认 bot 已加入频道;在 oncall 模式下需要 @mention;onchar 模式需要触发前缀;或把 chatmode 设为 onmessage。

- 鉴权错误:检查 bot token、base URL,以及账号是否启用。

- 多账号异常:环境变量只作用于 default 账号。