aiohttp, which is already a Mibyan dependency.
Before setup, here’s the part most people want to know: how Mibyan behaves once it’s in your Mattermost instance.
How Mibyan Behaves
Session Model in Mattermost
By default:- each DM gets its own session
- each thread gets its own session namespace
- each user in a shared channel gets their own session inside that channel
config.yaml:
false only if you explicitly want one shared conversation for the entire channel:
- users share context growth and token costs
- one person’s long tool-heavy task can bloat everyone else’s context
- one person’s in-flight run can interrupt another person’s follow-up in the same channel
Step 1: Enable Bot Accounts
Bot accounts must be enabled on your Mattermost server before you can create one.- Log in to Mattermost as a System Admin.
- Go to System Console → Integrations → Bot Accounts.
- Set Enable Bot Account Creation to true.
- Click Save.
If you don’t have System Admin access, ask your Mattermost administrator to enable bot accounts and create one for you.
Step 2: Create a Bot Account
- In Mattermost, click the ☰ menu (top-left) → Integrations → Bot Accounts.
- Click Add Bot Account.
- Fill in the details:
- Username: e.g.,
mibyan - Display Name: e.g.,
Mibyan - Description: optional
- Role:
Memberis sufficient
- Username: e.g.,
- Click Create Bot Account.
- Mattermost will display the bot token. Copy it immediately.
Step 3: Add the Bot to Channels
The bot needs to be a member of any channel where you want it to respond:- Open the channel where you want the bot.
- Click the channel name → Add Members.
- Search for your bot username (e.g.,
mibyan) and add it.
Step 4: Find Your Mattermost User ID
Mibyan uses your Mattermost User ID to control who can interact with the bot. To find it:- Click your avatar (top-left corner) → Profile.
- Your User ID is displayed in the profile dialog — click it to copy.
3uo8dkh1p7g1mfk49ear5fzs5c.
Alternative: You can also get your User ID via the API:
Step 5: Configure Mibyan
Option A: Interactive Setup (Recommended)
Run the guided setup command:Option B: Manual Configuration
Add the following to your~/.mibyan/.env file:
~/.mibyan/config.yaml:
group_sessions_per_user: truekeeps each participant’s context isolated inside shared channels and threads
Start the Gateway
Once configured, start the Mattermost gateway:Home Channel
You can designate a “home channel” where the bot sends proactive messages (such as cron job output, reminders, and notifications). There are two ways to set it:Using the Slash Command
Type/sethome in any Mattermost channel where the bot is present. That channel becomes the home channel.
Manual Configuration
Add this to your~/.mibyan/.env:
Reply Mode
TheMATTERMOST_REPLY_MODE setting controls how Mibyan posts responses:
Set it in your
~/.mibyan/.env:
Mention Behavior
By default, the bot only responds in channels when@mentioned. You can change this:
To find a channel ID in Mattermost: open the channel, click the channel name header, and look for the ID in the URL or channel details.
When the bot is
@mentioned, the mention is automatically stripped from the message before processing.
Channel allowlist (allowed_channels)
Restrict the bot to a fixed set of Mattermost channels. When set, the bot only responds in channels whose ID appears in the list — messages from any other channel are silently ignored, even if the bot is @mentioned.
DMs are exempt from this filter, so authorized users can always reach the bot in a direct message.
- Empty / unset → no restriction (fully backward compatible).
- Non-empty → channel ID must be on the list, or the message is dropped before any other gating (mention requirement,
MATTERMOST_FREE_RESPONSE_CHANNELS, etc.) runs. - Find a channel ID via the Mattermost UI → channel header → “View Info”, or read it from the channel URL.
Troubleshooting
Bot is not responding to messages
Cause: The bot is not a member of the channel, orMATTERMOST_ALLOWED_USERS doesn’t include your User ID.
Fix: Add the bot to the channel (channel name → Add Members → search for the bot). Verify your User ID is in MATTERMOST_ALLOWED_USERS. Restart the gateway.
403 Forbidden errors
Cause: The bot token is invalid, or the bot doesn’t have permission to post in the channel. Fix: Check thatMATTERMOST_TOKEN in your .env file is correct. Make sure the bot account hasn’t been deactivated. Verify the bot has been added to the channel. If using a personal access token, ensure your account has the required permissions.
WebSocket disconnects / reconnection loops
Cause: Network instability, Mattermost server restarts, or firewall/proxy issues with WebSocket connections. Fix: The adapter automatically reconnects with exponential backoff (2s → 60s). Check your server’s WebSocket configuration — reverse proxies (nginx, Apache) need WebSocket upgrade headers configured. Verify no firewall is blocking WebSocket connections on your Mattermost server. For nginx, ensure your config includes:“Failed to authenticate” on startup
Cause: The token or server URL is incorrect. Fix: VerifyMATTERMOST_URL points to your Mattermost server (include https://, no trailing slash). Check that MATTERMOST_TOKEN is valid — try it with curl:
Bot is offline
Cause: The Mibyan gateway isn’t running, or it failed to connect. Fix: Check thatmibyan gateway is running. Look at the terminal output for error messages. Common issues: wrong URL, expired token, Mattermost server unreachable.
”User not allowed” / Bot ignores you
Cause: Your User ID isn’t inMATTERMOST_ALLOWED_USERS.
Fix: Add your User ID to MATTERMOST_ALLOWED_USERS in ~/.mibyan/.env and restart the gateway. Remember: the User ID is a 26-character alphanumeric string, not your @username.
Per-Channel Prompts
Assign ephemeral system prompts to specific Mattermost channels. The prompt is injected at runtime on every turn — never persisted to transcript history — so changes take effect immediately.Security
For more information on securing your Mibyan deployment, see the Security Guide.Notes
- Self-hosted friendly: Works with any self-hosted Mattermost instance. No Mattermost Cloud account or subscription required.
- No extra dependencies: The adapter uses
aiohttpfor HTTP and WebSocket, which is already included with Mibyan. - Team Edition compatible: Works with both Mattermost Team Edition (free) and Enterprise Edition.

