Skip to main content

Mattermost

Last updated 10/07/2026

This article describes how to connect Mattermost to Agentic Engine. The channel sends and edits messages through the Mattermost REST API v4 and receives messages through WebSocket. User identity can be verified through OAuth authorization or a one-time binding code.

1. Prerequisites​

  • You have Mattermost system admin permissions and can create a Bot Account. If you need OAuth, you also need to create an OAuth 2.0 Application.
  • You have permission to access System Admin > Channels in Agentic Engine.
  • A Team and Channel are ready for the Bot to use.
  • The Agentic Engine server can access the Mattermost Site URL, /api/v4/**, and /api/v4/websocket.
  • If you need OAuth binding, prepare an Agentic Engine URL that users' browsers can access. We recommend HTTPS for production.
tip

Supported deployments: Both Mattermost Cloud and self-hosted deployments are supported. The Site URL can include a deployment subpath.

2. Create a Mattermost Bot and get credentials​

Use a Mattermost system admin account and follow these steps:

  1. Go to System Console → Integrations → Bot Accounts and set Enable Bot Account Creation to true.
  2. Open Product menu → Integrations → Bot Accounts and click Add Bot Account.
  3. Enter the Bot Username, Display Name, and Description. For production, we recommend keeping the regular Member role and granting permissions on the principle of least privilege.
  4. Click Create Bot Account and copy the generated Access Token right away.
  5. Add the Bot to the Team and Channel where you want to use it.
warning

The Bot Token is shown only once. Save it right away in a controlled password management system. Don't put it in code repositories, tickets, or chat logs. If the token is leaked, revoke it and generate a new one in Mattermost.

The Bot needs at least the following capabilities:

CapabilityPurpose
Read the target ChannelReceive messages in direct messages, public channels, private channels, and group chats.
Create PostsSend regular replies and final results.
Edit Posts it createdShow streaming replies in the same Post.
Read and upload filesProcess user attachments and send files generated by the Agent back to the original channel and thread.

Record the Mattermost Site URL​

Record the URL of your Mattermost site, for example:

Mattermost Site URL
https://chat.example.com

If the site is deployed under a subpath, you can enter:

https://example.com/mattermost

Don't append /api/v4, query parameters, or fragments, and don't embed a username and password in the URL.

3. Create an OAuth 2.0 app (optional)​

OAuth isn't required for the bot to send and receive messages. With OAuth turned off, users can still bind their accounts with a 6-digit one-time binding code. If you want users to authorize and bind directly after they click the entry, continue with the following configuration:

  1. Go to System Console → Integrations → Integration Management and set Enable OAuth 2.0 Service Provider to true.
  2. Go to Product menu → Integrations → OAuth 2.0 Applications and click Add OAuth 2.0 Application.
  3. Set Is Public Client to No to create a Confidential Client.
  4. We recommend keeping Is Trusted set to No so that users explicitly confirm the authorization when they bind for the first time.
  5. Enter the Callback URL. After you save, record the Client ID and Client Secret.

The Callback URL must exactly match the actual Agentic Engine access URL:

https://your-domain/agent/api/mattermost-oauth/callback
tip

OAuth applications are registered per Mattermost instance. The Client ID, Client Secret, and Server URL must belong to the same Mattermost instance and can't be reused across instances.

4. Add a Mattermost channel in Agentic Engine​

As an admin, log in to Agentic Engine and go to System Admin > Channels:

  1. Click New Channel and select Mattermost as the channel type.
  2. Fill in the following configuration items.
Config itemsRequiredDescription
Channel NameRequiredDisplay name, such as "Mattermost Bot".
Server URLRequiredMattermost Site URL. It can include a deployment subpath but must not include /api/v4.
Bot TokenRequiredThe Access Token generated after you create the Bot Account.
Enable OAuth bindingOptionalWhen turned on, users authorize through the browser first. When turned off, users can still use a one-time binding code.
OAuth Client IDConditionally requiredRequired when OAuth is enabled.
OAuth Client SecretConditionally requiredRequired when OAuth is enabled.
Default ModelOptionalIf not selected, the system-wide default model is used.
System PromptOptionalApplies only to Agent sessions in this channel.
  1. Click Save, and then turn on the channel's Enable switch.
  2. Confirm that the channel status is normal. When the channel is enabled, the system calls /api/v4/users/me to verify the Bot Token and Bot identity, and then connects to <Site URL>/api/v4/websocket.
tip

Editing secrets: When you edit an existing channel, leaving the Bot Token or OAuth Client Secret empty keeps the original value. The system doesn't display saved secrets.

5. Bind a Mattermost account​

Method 1: OAuth authorization binding​

  1. Log in to Agentic Engine, click the personal menu in the lower-left corner, and select Mattermost.
  2. The browser opens the authorization page of the current Mattermost instance.
  3. Log in and confirm the authorization. When it's done, the window closes and the status in the menu changes to Bound.

The OAuth access token is used only briefly during the callback. It isn't written to the database and doesn't replace the Bot Token in the channel configuration.

Method 2: One-time binding code​

If OAuth isn't enabled, or if the system can't get the authorization URL, the authorization URL is invalid, or the browser blocks the authorization window, the binding code is used automatically:

  1. Click Mattermost in the personal menu in the lower-left corner.
  2. Copy the binding command in the dialog.
  3. In Mattermost, send the command to the Bot in a direct message.
  4. After the Bot replies that binding succeeded, Agentic Engine automatically refreshes the binding status.
绑定命令示例
+bind ABC234
warning

By default, the binding code is valid for 10 minutes and can be used only once. To prevent leaks, the system doesn't accept binding commands in channels or group chats. A Mattermost account can't be bound to multiple Agentic Engine users at the same time.

Unbind​

  1. Click the personal menu in the lower-left corner, and click Unbind in the Mattermost row.
  2. After you confirm, the status changes to Unbound. To switch to a different Agentic Engine account, unbind the original account first.

6. How to use​

ScenarioOperations
Direct messagesSend your question to the Bot directly.
Public/private channels and group chatsUse @Bot用户名 问题内容. Regular messages that don't @mention the Bot are ignored.
ThreadsWhen you ask in an existing thread, the reply stays in that thread. When you ask from a root message in a channel, the Bot replies in a new thread with that message as the root.
Waiting for user responseClick Enter answers to open a Dialog, or reply with text as the Bot prompts. When the maximum number of rounds is reached, click Continue execution or reply Continue.
Send attachments to an AgentIn direct messages, send attachments directly. In channels, @mention the Bot in the body of the attachment message.
Receive Agent filesFiles generated by the Agent are sent back to the original channel and thread as new Posts.
Task notificationsYou can select Mattermost for Agent Team instant tasks and scheduled tasks. Results are sent as a direct message to the task creator's bound account.

Common commands​

CommandDescriptionExample
+bind <CODE>Bind an account with a one-time binding code.+bind ABC234
+newStart a new session.+new
+agent <Agent名称> <问题>Send a message to a specified Agent.+agent rhea 帮我分析数据

In channels, you still need to @mention the Bot with @Bot用户名 before you use a command.

7. Troubleshooting​

Invalid configuration error on save​

  • The Server URL must be a complete http:// or https:// URL.
  • Don't include /api/v4, and don't include a query, fragment, or credentials embedded in the URL.
  • The Bot Token can't be empty when you create a channel. Only when you edit a channel does leaving it empty keep the old token.

Channel goes offline or reconnects repeatedly after it's enabled​

  • Use the same Bot Token to request GET <Site URL>/api/v4/users/me, and confirm that it returns the Bot user.
  • Check DNS, TLS, and network connectivity from Agentic Engine to Mattermost.
  • Make sure that the reverse proxy allows WebSocket Upgrade for /api/v4/websocket.
  • Make sure that the Bot hasn't been deleted or disabled, and that the token hasn't been revoked or regenerated.

Bot doesn't receive channel messages​

  • Make sure that the Bot has joined the target Team and Channel.
  • In public channels, private channels, and group chats, you must @mention the Bot correctly with @Bot用户名.
  • Make sure that the channel is enabled and its status is normal.

Can receive messages but can't reply​

  • Make sure that the Bot has permission to create Posts in the target Channel.
  • Streaming replies require that the Bot can edit Posts it created.
  • If you use an advanced permission scheme, make sure that members aren't prohibited from editing their own Posts.

Attachments fail to upload or download​

  • Make sure that the Bot is a member of the target Channel and has permission to read and upload files.
  • Check whether channel.mattermost.fileUploads.enabled is turned on, and check the size, count, and timeout limits.
  • By default, up to 5 attachments are processed per message, each no larger than 2 MiB. Files whose extension, MIME type, and actual content don't match may be rejected.

Binding code is invalid​

  • Generate a new binding code and use it within 10 minutes.
  • Make sure that the command is sent to the Mattermost Bot configured for the current tenant.
  • The binding command can be sent only in a direct message with the Bot.

OAuth authorization fails​

  • Make sure that OAuth 2.0 Service Provider is enabled in Mattermost and that the OAuth Application is a Confidential Client.
  • Make sure that the Client ID, Client Secret, and Server URL belong to the same Mattermost instance.
  • The Callback URL must exactly match the URL shown in the Agentic Engine admin interface, including the actual basePath.
  • Add the Agentic Engine Origin to ALLOWED_ORIGINS. In production, use HTTPS and make sure that the cookie security settings match the protocol.
  • For local access, use the real browser Origin, such as http://localhost:3000. Don't enter 0.0.0.0 in the OAuth Callback URL.

Related pages and next steps

Was this page helpful?