Channels
How to Connect OpenClaw to Mattermost
Browse more in Channels.
All channels guides →This guide walks you through how to connect OpenClaw to Mattermost so your agents can chat in channels, groups, and DMs. You’ll set up the bundled Mattermost plugin, wire it to your Mattermost server, and tune chat behavior like mentions, threading, and access control.
By the end, your OpenClaw gateway will be talking to your Mattermost workspace with optional slash commands and interactive buttons.
Prerequisites
- ✓A running Mattermost server with access to create a bot account and obtain a bot token.
- ✓An OpenClaw gateway installation that can load bundled plugins and reach your Mattermost server over HTTPS.
- ✓A Mattermost base URL such as `https://chat.example.com` that OpenClaw can reach from the gateway host.
Steps
- 1
Ensure the Mattermost plugin is available in OpenClaw
OpenClaw’s Mattermost support ships as a bundled plugin in current releases, so most installs work out of the box. If you run an older build or a custom install that excludes Mattermost, install the plugin explicitly so the gateway can connect to your server.
bashopenclaw plugins install @openclaw/mattermost - 2
Install the Mattermost plugin from a local checkout when developing
If you work from a git repo and have the Mattermost plugin checked out locally, point OpenClaw at that path. This is useful when you modify the plugin and want the gateway to load your local version instead of the npm package.
bashopenclaw plugins install ./path/to/local/mattermost-plugin - 3
Create a Mattermost bot and collect the bot token and base URL
In your Mattermost server, create a bot account and copy its bot token; OpenClaw uses this to authenticate API calls and WebSocket events. com`) so the plugin knows where to connect.
- 4
Configure the Mattermost channel in OpenClaw
Add a minimal Mattermost channel configuration so the gateway can log in with your bot and start handling DMs and channels. This is the core wiring: enable the plugin, set the bot token, base URL, and DM policy, then start or reload your gateway.
json{ channels: { mattermost: { enabled: true, botToken: "mm-token", baseUrl: "https://chat.example.com", dmPolicy: "pairing", }, }, } - 5
Optionally configure Mattermost via environment variables
If you prefer env vars over inline config for the default account, set the Mattermost bot token and URL on the gateway host. These only apply to the `default` account, so keep that in mind if you later add multi-account setups.
bashMATTERMOST_BOT_TOKEN=... MATTERMOST_URL=https://chat.example.com - 6
Enable native slash commands for Mattermost
To let users trigger agents with `/oc_*` commands, turn on native slash commands in the Mattermost channel config. You can also set a public `callbackUrl` when Mattermost cannot reach the gateway directly, which is common when the gateway sits behind a reverse proxy.
json{ channels: { mattermost: { commands: { native: true, nativeSkills: true, callbackPath: "/api/channels/mattermost/command", // Use when Mattermost cannot reach the gateway directly (reverse proxy/public URL). callbackUrl: "https://gateway.example.com/api/channels/mattermost/command", }, }, }, } - 7
Tune chat modes and channel behavior
Control how your agent responds in Mattermost channels by setting `chatmode` and optional trigger prefixes. This lets you keep channels quiet until mentioned, respond to every message, or only react when messages start with specific characters.
json{ channels: { mattermost: { chatmode: "onchar", oncharPrefixes: [">", "!"], }, }, } - 8
Configure threading and sessions for channel replies
Decide whether the agent replies inline in channels or starts threads under the triggering post. Thread-scoped sessions keep long conversations organized and easier to follow for your team.
json{ channels: { mattermost: { replyToMode: "all", }, }, } - 9
Set DM access control and group policies
Lock down who can DM the bot and how it behaves in channels by configuring DM policy, allowlists, and per-channel mention rules. This prevents the agent from responding in places you don’t expect and gives you fine-grained control over exposure.
json{ channels: { mattermost: { groupPolicy: "open", groups: { "*": { requireMention: true }, "team-channel-id": { requireMention: false }, }, }, }, } - 10
Enable interactive buttons and reactions for richer UX
Turn on inline buttons so your agent can send clickable options, and use the reactions message tool to react to posts. Buttons require the `inlineButtons` capability and a reachable callback URL from the Mattermost server.
json{ channels: { mattermost: { capabilities: ["inlineButtons"], }, }, } - 11
Configure multi-account Mattermost setups in OpenClaw
accounts`. Each account gets its own bot token and base URL, and you can override settings like DM retry or commands per account.
json{ 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" }, }, }, }, }
Configuration
| Option | Description | Example |
|---|---|---|
| channels.mattermost.enabled | Turns the Mattermost channel plugin on or off in the OpenClaw gateway. | true |
| channels.mattermost.botToken | The Mattermost bot token used for API calls and WebSocket authentication. | mm-token |
| channels.mattermost.baseUrl | The base URL of your Mattermost server that the plugin connects to. | https://chat.example.com |
| channels.mattermost.dmPolicy | Controls DM access behavior, including pairing and open DMs. | pairing |
| MATTERMOST_BOT_TOKEN | Environment variable for the default Mattermost account bot token. | mm-token |
| MATTERMOST_URL | Environment variable for the default Mattermost account base URL. | https://chat.example.com |
| channels.mattermost.commands.native | Enables native Mattermost slash commands for the Mattermost channel. | true |
| channels.mattermost.commands.nativeSkills | Controls whether native slash commands expose skills via Mattermost. | true |
| channels.mattermost.commands.callbackPath | HTTP path on the gateway that receives Mattermost slash command callbacks. | /api/channels/mattermost/command |
| channels.mattermost.commands.callbackUrl | Full URL Mattermost calls for slash command callbacks when it cannot reach the gateway directly. | https://gateway.example.com/api/channels/mattermost/command |
| channels.mattermost.chatmode | Defines how the bot responds in channels: on mention, every message, or trigger prefix. | onchar |
| channels.mattermost.oncharPrefixes | List of prefixes that trigger responses when chatmode is set to onchar. | [">", "!"] |
| channels.mattermost.replyToMode | Controls whether replies stay in the main channel or start threads. | all |
| channels.mattermost.groupPolicy | Controls whether channels are open or mention-gated via an allowlist. | open |
| channels.mattermost.groups["*"].requireMention | Default per-channel rule for whether the bot requires a mention to respond. | true |
| channels.mattermost.groups["team-channel-id"].requireMention | Per-channel override for mention requirements in a specific Mattermost channel. | false |
| channels.mattermost.dmChannelRetry.maxRetries | Maximum number of retries when creating a DM channel via the Mattermost API. | 3 |
| channels.mattermost.dmChannelRetry.initialDelayMs | Initial delay in milliseconds before retrying DM channel creation. | 1000 |
| channels.mattermost.dmChannelRetry.maxDelayMs | Maximum backoff delay in milliseconds between DM channel retries. | 10000 |
| channels.mattermost.dmChannelRetry.timeoutMs | Total timeout in milliseconds for DM channel creation retries. | 30000 |
| channels.mattermost.actions.reactions | Enables or disables reaction actions for the Mattermost channel. | true |
| channels.mattermost.capabilities | List of capability strings; include inlineButtons to enable interactive buttons. | ["inlineButtons"] |
| channels.mattermost.interactions.callbackBaseUrl | External base URL used for button callbacks when Mattermost cannot reach the gateway bind host. | https://gateway.example.com |
| channels.mattermost.accounts.default.name | Display name for the default Mattermost account in multi-account setups. | Primary |
| channels.mattermost.accounts.default.botToken | Bot token for the default Mattermost account in multi-account setups. | mm-token |
| channels.mattermost.accounts.default.baseUrl | Base URL for the default Mattermost account in multi-account setups. | https://chat.example.com |
| channels.mattermost.accounts.alerts.name | Display name for a secondary Mattermost account, such as an alerts bot. | Alerts |
| channels.mattermost.accounts.alerts.botToken | Bot token for the secondary Mattermost account. | mm-token-2 |
| channels.mattermost.accounts.alerts.baseUrl | Base URL for the secondary Mattermost account. | https://alerts.example.com |
Troubleshooting
No replies in channels
Mattermost may be connected but the bot is either not in the channel or gated by chat mode. Ensure the bot is a member of the channel and either mention it (oncall), use a trigger prefix (onchar), or set `chatmode: "onmessage"` if you want it to respond to every message.
Auth errors when connecting to Mattermost
Authentication failures usually mean the bot token or base URL is wrong, or the account is disabled. Double-check the bot token from Mattermost, verify the `baseUrl` matches your server, and confirm the Mattermost account is enabled in your OpenClaw config.
Native slash commands return 'Unauthorized: invalid command token.'
OpenClaw is rejecting the callback token, often because slash command registration failed, the callback is hitting the wrong gateway/account, or Mattermost still has old commands pointing at a previous callback target. Restart the gateway so commands register cleanly and ensure Mattermost points to the correct callback URL and account.
Native slash commands stop working after a restart
If commands silently fail, check the gateway logs for `mattermost: failed to register slash commands` or `mattermost: native slash commands enabled but no commands could be registered`. Fix any registration issues (like unreachable callback URLs), then restart the gateway so it can register commands successfully.
Buttons render but clicks do nothing
Mattermost may be blocking post action integrations or cannot reach the callback. 1 localhost`, and ensure `EnablePostActionIntegration` is `true` in `ServiceSettings` so button clicks reach OpenClaw.
Buttons return 404 on click
Mattermost’s action router breaks when button IDs contain hyphens or underscores, causing 404s. Ensure your button `id` values are alphanumeric only (`[a-zA-Z0-9]`) so routing works correctly.
id: "mybutton01" // alphanumeric only — see below
Gateway logs 'invalid _token' for button clicks
The HMAC token in the button context does not match what the gateway expects, usually because you signed only a subset of fields, didn’t sort keys, or used JSON with spaces. Regenerate `_token` by signing all context fields (minus `_token`) with sorted keys and compact JSON as described in the HMAC section.
Agent doesn’t know about buttons
If the agent ignores button capabilities, the Mattermost channel config likely lacks the inlineButtons capability. mattermost` so the agent system prompt includes button support.
Frequently asked questions
Powered by Mem0
Add persistent memory to OpenClaw
Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.