Mattermost (plugin)
状态:通过 Plugin 支持(bot token + WebSocket 事件)。支持 Channel、群组和 DM。 Mattermost 是一个可以自己部署的团队消息平台;访问官网 mattermost.com 了解产品详情和下载。
需要安装 Plugin
Mattermost 以 Plugin 形式提供,不包含在核心安装包中。
通过 CLI 安装(npm 仓库):
openclaw plugins install @openclaw/mattermost
本地安装(从 git 仓库运行时):
openclaw plugins install ./extensions/mattermost
如果你在配置/引导过程中选择 Mattermost,并且检测到 git 仓库,OpenClaw 会自动提供本地安装路径。
详情:Plugins
快速设置
- 安装 Mattermost Plugin。
- 创建一个 Mattermost 机器人账号,复制 bot token。
- 复制 Mattermost 的 base URL(例如
https://chat.example.com)。 - 配置 OpenClaw 并启动 Gateway。
最小配置:
{
channels: {
mattermost: {
enabled: true,
botToken: "mm-token",
baseUrl: "https://chat.example.com",
dmPolicy: "pairing",
},
},
}
环境变量(默认账号)
如果你更喜欢用环境变量,可以在 Gateway 主机上设置:
MATTERMOST_BOT_TOKEN=...MATTERMOST_URL=https://chat.example.com
环境变量只对 默认 账号(default)生效。其他账号必须使用配置文件。
聊天模式
Mattermost 会自动响应 DM。Channel 的行为由 chatmode 控制:
oncall(默认):只在 Channel 中被 @提及时响应。onmessage:响应 Channel 中的每条消息。onchar:当消息以触发前缀开头时响应。
配置示例:
{
channels: {
mattermost: {
chatmode: "onchar",
oncharPrefixes: [">", "!"],
},
},
}
注意:
onchar模式仍然会响应明确的 @提及。channels.mattermost.requireMention在旧配置中仍然有效,但推荐使用chatmode。
访问控制(DM)
- 默认:
channels.mattermost.dmPolicy = "pairing"(未知发送者会收到配对码)。 - 通过以下方式批准:
openclaw pairing list mattermostopenclaw pairing approve mattermost <CODE>
- 公开 DM:设置
channels.mattermost.dmPolicy="open"加上channels.mattermost.allowFrom=["*"]。
Channel(群组)
- 默认:
channels.mattermost.groupPolicy = "allowlist"(需要提及才能触发)。 - 用
channels.mattermost.groupAllowFrom设置白名单发送者(用户 ID 或@username)。 - 开放 Channel:
channels.mattermost.groupPolicy="open"(需要提及才能触发)。
出站消息目标
在 openclaw message send 或 cron/webhook 中使用这些目标格式:
channel:<id>发送到 Channeluser:<id>发送 DM@username发送 DM(通过 Mattermost API 解析)
单独的 ID 会被当作 Channel 处理。
多账号
Mattermost 支持在 channels.mattermost.accounts 下配置多个账号:
{
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" },
},
},
},
}
故障排除
- Channel 中没有回复:确保机器人在 Channel 中,并且提及它(oncall 模式),或使用触发前缀(onchar 模式),或设置
chatmode: "onmessage"。 - 认证错误:检查 bot token、base URL,以及账号是否已启用。
- 多账号问题:环境变量只对
default账号生效。