chat-adapter-mattermost
Mattermost adapter for Vercel Chat SDK.
Install
Requires Node.js >= 20 and a Mattermost server with a bot account.
Quick start
Configuration can also be provided through environment variables:
Mattermost setup
-
Create a bot account -- In Mattermost, go to System Console > Integrations > Bot Accounts and create a new bot. Copy the generated access token.
-
Enable integrations -- Make sure your Mattermost server allows bot accounts and has the REST API and WebSocket gateway accessible. These are enabled by default.
-
Add the bot to channels -- Add the bot user to any channels where it should respond. The bot will only receive events from channels it is a member of.
-
Interactive actions (optional) -- To use buttons and selects, set
callbackUrlto a public URL that Mattermost can reach. The adapter exposeshandleWebhook()for this purpose:Register this URL in System Console > Integrations > Interactive Dialogs or per-post via the
integrationfield.
Feature Support
Notes
- The adapter connects to Mattermost over the REST API v4 and the
/api/v4/websocketgateway. - Thread IDs are encoded as
mattermost:<base64url(channelId)>for channel-level contexts ormattermost:<base64url(channelId)>:<base64url(rootPostId)>for threaded replies. - User and channel data are cached in-memory with LRU eviction (up to 1000 entries each).
- WebSocket reconnection uses exponential backoff with jitter (1 s base, 30 s max).
- This is a community adapter. The
@chat-adapter/*npm scope is reserved for official adapters; this package is published aschat-adapter-mattermost.
License
MIT [blocked] © Thiago Ferolla