Skip to content

Mattermost Setup

The Mattermost adapter connects to any Mattermost instance using the REST v4 API and WebSocket for real-time message events.

Max message length: 4000 characters.


  1. A Mattermost instance (self-hosted or cloud)
  2. A bot account or personal access token with create_post permissions
  3. The bot added to at least one channel

VariableRequiredDescription
MATTERMOST_URLYesServer URL (e.g. https://chat.example.com)
MATTERMOST_TOKENYesBot token or personal access token
MATTERMOST_ALLOWED_USERSNoComma-separated Mattermost user IDs

In Mattermost System Console → Integrations → Bot Accounts, create a new bot. Copy the access token.

Alternatively, use a personal access token: Account Settings → Security → Personal Access Tokens.

~/.edgecrab/.env
MATTERMOST_URL=https://chat.example.com
MATTERMOST_TOKEN=your-bot-token
MATTERMOST_ALLOWED_USERS=user1_id,user2_id

In Mattermost, add the bot to any channels it should respond in.

Terminal window
edgecrab gateway start

  • Mention the bot in a channel: @edgecrab-bot explain this PR
  • DM the bot directly for a private conversation
  • Each channel maintains its own persistent EdgeCrab session

Gateway slash commands (send as Mattermost messages):

CommandEffect
/helpList all available gateway commands
/newStart a fresh conversation (clears history)
/resetAlias for /new
/stopCancel the currently running agent response
/retryRe-send your last message
/statusShow whether the agent is running or idle
/usageShow session stats (running, queued, retryable)
/hooksList loaded event hooks

SymptomCauseFix
401 UnauthorizedWrong tokenCheck MATTERMOST_TOKEN
Bot doesn’t see messagesNot in channelAdd bot to the channel
WebSocket disconnectNetwork issueGateway auto-reconnects with exponential backoff

  • Bot account vs. personal access token: Use a dedicated bot account for production. Bot accounts can be disabled centrally, don’t count against your license seat on Enterprise, and show a distinct bot icon in channels.
  • System Console permissions: Bot accounts need create_post permission explicitly enabled in System Console → Integration Management → Enable Bot Account Creation.
  • Channel naming convention: Name the bot @edgecrab for auto-complete discoverability. Users can mention it without remembering exotic names.
  • Self-hosted Mattermost: Set MATTERMOST_URL without a trailing slash. The adapter appends API paths internally.
  • Message threads: Mattermost thread replies maintain context from the parent post. Replies in a thread go to the same EdgeCrab session as the channel.

Q: Bot joins the channel but never responds to @mentions.
Check that Event Subscriptions are enabled in your Mattermost app configuration. The adapter uses REST polling if WebSocket fails, so check MATTERMOST_URL is reachable and the token is valid.

Q: Can I use Mattermost slash commands (not just messages)?
Not currently — EdgeCrab responds to DMs and @mentions, not registered Mattermost slash commands. The /help, /new, etc. commands above are sent as messages, not registered slash command endpoints.

Q: Does EdgeCrab work with Mattermost Cloud?
Yes — set MATTERMOST_URL to your cloud URL (e.g. https://yourteam.mattermost.com) and use a personal access token from your account settings.

Q: Can multiple team members share one EdgeCrab session in a channel?
Yes — all messages in a channel share one session. This is useful for shared project channels but means context can mix between users. Use DMs for private, per-user sessions.

Q: The WebSocket shows 403 in logs.
Ensure your Mattermost instance allows WebSocket connections. Some reverse proxies (nginx, Apache) need Upgrade: websocket headers forwarded. Add proxy_set_header Upgrade $http_upgrade; to your proxy config.