OpenClaw Mattermost 渠道
将 OpenClaw 连接到 Mattermost 这一开源企业消息平台,使您的 AI 助手能够参与私信、群组频道和团队对话。该集成使用 Bot Token 认证和 WebSocket 事件进行实时双向通信,支持灵活的聊天模式和细粒度的访问控制策略。
Mattermost 支持的功能
文本消息
支持
媒体与文件
支持
消息反应
支持
消息线程
支持
语音消息
不支持
群聊
支持
Mattermost 前置条件
- 一台 Mattermost 服务器(自托管或云端),并拥有管理员权限以创建 Bot 账户
- 在 Mattermost 系统控制台中创建的 Bot 账户及其 Bot Token
- Mattermost 服务器的 Base URL 可从 OpenClaw Gateway 访问
- 已安装并运行 OpenClaw Gateway
- 已通过 'openclaw plugins install @openclaw/mattermost' 安装 Mattermost 插件
Mattermost 快速设置
安装 Mattermost 插件
运行 'openclaw plugins install @openclaw/mattermost' 为您的 Gateway 添加 Mattermost 支持。
在 Mattermost 中创建 Bot 账户
前往 Mattermost 系统控制台 > Integrations > Bot Accounts。点击 'Add Bot Account',设置显示名称和描述,然后复制生成的 Bot Token。确保在系统控制台 > Integrations > Integration Management 中将 'Enable Bot Account Creation' 设置为 true。
配置并启动
在 ~/.openclaw/openclaw.json 中添加 Mattermost 渠道配置,填入您的 botToken、baseUrl 和所需的策略。使用 'openclaw start' 启动 Gateway。向 Bot 发送私信或在频道中 @提及它以验证连接。
Mattermost 配置示例
{
"channels": {
"mattermost": {
"enabled": true,
"botToken": "your-bot-token",
"baseUrl": "https://mattermost.example.com",
"dmPolicy": "pairing",
"chatmode": "oncall"
}
}
}Mattermost 深入了解
架构概览
创建 Bot 账户
{
"channels": {
"mattermost": {
"botToken": "your-bot-token",
"baseUrl": "https://mattermost.example.com"
}
}
}聊天模式
{
"channels": {
"mattermost": {
"chatmode": "onchar",
"oncharPrefixes": ["!", "/ai"]
}
}
}DM 策略
{
"channels": {
"mattermost": {
"dmPolicy": "pairing",
"allowFrom": ["user-id-1", "user-id-2"]
}
}
}群组和频道策略
{
"channels": {
"mattermost": {
"groupPolicy": "allowlist",
"groupAllowFrom": ["channel-id-1", "channel-id-2"]
}
}
}多账户设置
{
"channels": {
"mattermost": {
"accounts": {
"production": {
"botToken": "prod-bot-token",
"baseUrl": "https://mattermost.company.com",
"chatmode": "oncall",
"dmPolicy": "pairing",
"allowFrom": ["user-1", "user-2"]
},
"dev-team": {
"botToken": "dev-bot-token",
"baseUrl": "https://mm-dev.company.com",
"chatmode": "onmessage",
"dmPolicy": "open"
}
}
}
}
}主动消息发送
{
"action": "mattermost",
"params": {
"message": "Daily standup reminder: please post your updates!",
"to": "channel:abc123def456"
}
}富消息功能
速率限制与最佳实践
Mattermost 配置参考
| Key | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | 启用或禁用 Mattermost 渠道 |
| botToken | string | "" | 从 Mattermost 系统控制台 > Bot Accounts 获取的 Bot Token |
| baseUrl | string | "" | Mattermost 服务器的完整 URL(例如 https://mattermost.example.com) |
| chatmode | string | "oncall" | 聊天触发模式:'oncall'(提及触发)、'onmessage'(所有消息)或 'onchar'(前缀触发) |
| oncharPrefixes | string[] | [] | 当 chatmode 为 'onchar' 时触发 Bot 的前缀字符 |
| dmPolicy | string | "pairing" | DM 访问策略:'pairing'(仅允许列表中的用户)或 'open'(任何用户) |
| allowFrom | string[] | [] | 允许向 Bot 发送私信的 Mattermost 用户 ID(与 dmPolicy: pairing 配合使用) |
| groupPolicy | string | "allowlist" | 群组频道策略:'allowlist'(仅指定频道)或 'open'(任何频道) |
| groupAllowFrom | string[] | [] | 允许 Bot 响应的 Mattermost 频道 ID(与 groupPolicy: allowlist 配合使用) |
| requireMention | boolean | true | 旧版设置 -- 建议使用 chatmode: 'oncall' 代替 |
| accounts.<id>.botToken | string | "" | 多账户模式中特定账户的 Bot Token |
| accounts.<id>.baseUrl | string | "" | 特定账户的 Mattermost 服务器 URL |
| accounts.<id>.chatmode | string | "oncall" | 特定账户的聊天触发模式 |
| accounts.<id>.dmPolicy | string | "pairing" | 特定账户的 DM 访问策略 |
启用或禁用 Mattermost 渠道
从 Mattermost 系统控制台 > Bot Accounts 获取的 Bot Token
Mattermost 服务器的完整 URL(例如 https://mattermost.example.com)
聊天触发模式:'oncall'(提及触发)、'onmessage'(所有消息)或 'onchar'(前缀触发)
当 chatmode 为 'onchar' 时触发 Bot 的前缀字符
DM 访问策略:'pairing'(仅允许列表中的用户)或 'open'(任何用户)
允许向 Bot 发送私信的 Mattermost 用户 ID(与 dmPolicy: pairing 配合使用)
群组频道策略:'allowlist'(仅指定频道)或 'open'(任何频道)
允许 Bot 响应的 Mattermost 频道 ID(与 groupPolicy: allowlist 配合使用)
旧版设置 -- 建议使用 chatmode: 'oncall' 代替
多账户模式中特定账户的 Bot Token
特定账户的 Mattermost 服务器 URL
特定账户的聊天触发模式
特定账户的 DM 访问策略
Mattermost 常见问题
Mattermost 故障排查
聊天模式或访问策略可能过滤了消息。
baseUrl 不正确、Bot Token 无效或服务器不可达。
Bot 不是目标频道的成员。
Mattermost 服务器的文件上传设置可能限制了文件类型或大小。
Bot 在短时间内发送了过多的 API 请求。