OpenClaw Mattermost 頻道
將 OpenClaw 連接至 Mattermost——開源企業通訊平台,讓您的 AI 助手能夠參與私訊、群組頻道和團隊對話。整合使用 Bot Token 驗證與 WebSocket 事件實現即時雙向通訊,並提供彈性的聊天模式與精細的存取控制策略。
Mattermost 支援功能
文字訊息
支援
媒體與檔案
支援
表情回應
支援
討論串
支援
語音訊息
不支援
群組聊天
支援
Mattermost 前置條件
- 一個 Mattermost 伺服器(自行架設或雲端版),擁有管理員權限以建立 Bot 帳號
- 在 Mattermost System Console 中建立的 Bot Account 及其 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 Account
前往 Mattermost System Console > Integrations > Bot Accounts。點選「Add Bot Account」,設定顯示名稱與描述,然後複製產生的 Bot Token。請確認 System Console > Integrations > Integration Management 中的「Enable Bot Account Creation」已設為 true。
設定並啟動
在 ~/.openclaw/openclaw.json 中新增 Mattermost 頻道設定,填入您的 botToken、baseUrl 及所需策略。使用 'openclaw start' 啟動 Gateway。向機器人傳送私訊或在頻道中 @提及它以驗證連線是否正常。
Mattermost 設定範例
{
"channels": {
"mattermost": {
"enabled": true,
"botToken": "your-bot-token",
"baseUrl": "https://mattermost.example.com",
"dmPolicy": "pairing",
"chatmode": "oncall"
}
}
}Mattermost 深入了解
架構概述
建立 Bot Account
{
"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 System Console > Bot Accounts 的 Bot Token |
| baseUrl | string | "" | 您的 Mattermost 伺服器完整 URL(例如 https://mattermost.example.com) |
| chatmode | string | "oncall" | 聊天觸發模式:'oncall'(提及)、'onmessage'(全部)或 'onchar'(前綴字元) |
| oncharPrefixes | string[] | [] | 當 chatmode 為 'onchar' 時觸發機器人的前綴字元 |
| dmPolicy | string | "pairing" | DM 存取策略:'pairing'(僅允許清單)或 'open'(任何使用者) |
| allowFrom | string[] | [] | 允許向機器人發送 DM 的 Mattermost 使用者 ID(搭配 dmPolicy: pairing 使用) |
| groupPolicy | string | "allowlist" | 群組頻道策略:'allowlist'(僅指定頻道)或 'open'(任何頻道) |
| groupAllowFrom | string[] | [] | 允許機器人回覆的 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 System Console > Bot Accounts 的 Bot Token
您的 Mattermost 伺服器完整 URL(例如 https://mattermost.example.com)
聊天觸發模式:'oncall'(提及)、'onmessage'(全部)或 'onchar'(前綴字元)
當 chatmode 為 'onchar' 時觸發機器人的前綴字元
DM 存取策略:'pairing'(僅允許清單)或 'open'(任何使用者)
允許向機器人發送 DM 的 Mattermost 使用者 ID(搭配 dmPolicy: pairing 使用)
群組頻道策略:'allowlist'(僅指定頻道)或 'open'(任何頻道)
允許機器人回覆的 Mattermost 頻道 ID(搭配 groupPolicy: allowlist 使用)
舊版設定——建議改用 chatmode: 'oncall'
多帳號模式下特定帳號的 Bot Token
特定帳號的 Mattermost 伺服器 URL
特定帳號的聊天觸發模式
特定帳號的 DM 存取策略
Mattermost 常見問題
Mattermost 故障排除
聊天模式或存取策略可能過濾掉了訊息。
baseUrl 不正確、Bot Token 無效,或伺服器無法存取。
機器人不是目標頻道的成員。
Mattermost 伺服器的檔案上傳設定可能限制了檔案類型或大小。
機器人在短時間內發出了過多的 API 請求。