Mattermost(插件)
状态:通过插件支持(机器人令牌 + WebSocket 事件)。支持频道、群组和私信。 Mattermost 是一个可自托管的团队消息平台;有关产品详情和下载,请参见官方网站 mattermost.com。
需要插件
Mattermost 作为插件提供,不包含在核心安装中。
通过 CLI 安装(npm 注册表):
bash
openclaw plugins install @openclaw/mattermost本地检出(从 git 仓库运行时):
bash
openclaw plugins install ./extensions/mattermost如果您在配置/引导过程中选择 Mattermost 并检测到 git 检出, openclaw 将自动提供本地安装路径。
详情:插件
快速设置
- 安装 Mattermost 插件。
- 创建 Mattermost 机器人账户并复制 机器人令牌。
- 复制 Mattermost 基础 URL(例如,
https://chat.example.com)。 - 配置 openclaw 并启动网关。
最小配置:
json5
{
channels: {
mattermost: {
enabled: true,
botToken: "mm-token",
baseUrl: "https://chat.example.com",
dmPolicy: "pairing"
}
}
}环境变量(默认账户)
如果您更喜欢环境变量,请在网关主机上设置这些:
MATTERMOST_BOT_TOKEN=...MATTERMOST_URL=https://chat.example.com
环境变量仅适用于 默认 账户(default)。其他账户必须使用配置值。
聊天模式
Mattermost 自动响应私信。频道行为由 chatmode 控制:
oncall(默认):仅在频道中被 @提及 时响应。onmessage:响应每个频道消息。onchar:当消息以触发前缀开头时响应。
配置示例:
json5
{
channels: {
mattermost: {
chatmode: "onchar",
oncharPrefixes: [">", "!"]
}
}
}说明:
onchar仍然响应显式的 @提及。channels.mattermost.requireMention为旧版配置保留,但chatmode是首选。
访问控制(私信)
- 默认:
channels.mattermost.dmPolicy = "pairing"(未知发送者会收到配对码)。 - 通过以下方式批准:
openclaw pairing list mattermostopenclaw pairing approve mattermost <CODE>
- 公开私信:
channels.mattermost.dmPolicy="open"加上channels.mattermost.allowFrom=["*"]。
频道(群组)
- 默认:
channels.mattermost.groupPolicy = "allowlist"(提及门控)。 - 使用
channels.mattermost.groupAllowFrom允许列表发送者(用户 ID 或@username)。 - 开放频道:
channels.mattermost.groupPolicy="open"(提及门控)。
出站发送目标
使用这些目标格式与 openclaw message send 或 cron/webhooks:
channel:<id>用于频道user:<id>用于私信@username用于私信(通过 Mattermost API 解析)
Bare IDs are treated as channels.
Multi-account
Mattermost supports multiple accounts under 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" }
}
}
}
}Troubleshooting
- No replies in channels: ensure the bot is in the channel and mention it (oncall), use a trigger prefix (onchar), or set
chatmode: "onmessage". - Auth errors: check the bot token, base URL, and whether the account is enabled.
- Multi-account issues: env vars only apply to the
defaultaccount.