Beeper Matrix
Matrix adapter built and maintained by Beeper. Runs over Matrix sync (no webhooks) and works with Beeper conversations and bridged networks like WhatsApp, Telegram, Instagram, and Signal.
Install
Requires Node.js 22+.
pnpm add @beeper/chat-adapter-matrixQuick start
createMatrixAdapter() reads its configuration from environment variables when called without arguments.
Threads, direct messages, subscriptions, and handlers work the same as with other adapters. The Matrix adapter maps them onto Matrix rooms and threaded replies.
Authentication
The adapter supports two login modes. Both take the homeserver URL in baseURL.
Access token
Use a long-lived access token from your Matrix homeserver:
Username and password
The adapter persists the resulting login session through your state adapter, so subsequent restarts reuse the existing session instead of logging in again.
Configuration
Default behavior:
- Persistence turns on automatically whenever the
Chatinstance has astateadapter. Redis is recommended so state survives restarts. deviceIDis inferred from the auth payload when possible, then read back from state, and generated only as a last resort.recoveryKeyenables E2EE and key-backup bootstrap.inviteAutoJoin: {}enables invite auto-join. PassinviterAllowlistto limit it to specific accounts.
Advanced options
Environment variables
When you call createMatrixAdapter() with no arguments, the adapter reads only these variables:
| Variable | Required | Description |
|---|---|---|
MATRIX_BASE_URL | Yes | Matrix homeserver base URL |
MATRIX_ACCESS_TOKEN | Yes* | Access token for access-token auth |
MATRIX_USERNAME | Yes* | Username for password auth |
MATRIX_PASSWORD | Yes* | Password for password auth |
MATRIX_USER_ID | No | User ID hint |
MATRIX_DEVICE_ID | No | Explicit device ID override |
MATRIX_RECOVERY_KEY | No | Enables E2EE and key-backup bootstrap |
MATRIX_BOT_USERNAME | No | Mention-detection username |
MATRIX_COMMAND_PREFIX | No | Slash command prefix (default: /) |
MATRIX_INVITE_AUTOJOIN | No | Enable invite auto-join |
MATRIX_INVITE_AUTOJOIN_ALLOWLIST | No | Comma-separated Matrix user IDs allowed to invite the bot |
MATRIX_SDK_LOG_LEVEL | No | Matrix SDK log level |
*Use either MATRIX_ACCESS_TOKEN, or MATRIX_USERNAME plus MATRIX_PASSWORD.
Persistence
For production, pair the adapter with a durable state adapter such as Redis:
The state adapter persists:
- Generated or inferred device IDs
- Password-login sessions
- DM room mappings
- Matrix sync snapshots
- E2EE secrets bundles when E2EE is enabled
Message history
The adapter implements the standard fetch methods:
fetchMessage(threadId, messageId)fetchMessages(threadId, options)fetchChannelMessages(channelId, options)fetchThread(threadId)fetchChannelInfo(channelId)listThreads(channelId, options)openDM(userId)
Thread model
- A Matrix room is a Chat SDK channel.
- Top-level room messages live on the channel timeline.
- Matrix threaded replies map to Chat SDK threads using
roomID + rootEventID. openDM(userId)reuses an existing direct room when one is already in state and creates a new one otherwise.
Limitations
handleWebhook()returns501by design, because the adapter receives events through Matrix sync polling rather than webhooks.- Cards, modals, and ephemeral messages are not implemented because Matrix has no native equivalent.
- Native streaming is not implemented at the adapter layer.
- Slash commands are parsed from plain text messages because Matrix does not emit native slash command events.
Feature support
Messaging
| Feature | Supported |
|---|---|
| Post message | |
| Message replies | |
| Edit message | |
| Delete message | |
| File uploads | |
| Streaming | |
| Scheduled messages |
Rich content
| Feature | Supported |
|---|---|
| Card format | |
| Buttons | |
| Link buttons | |
| Select menus | |
| Tables | |
| Charts | |
| Fields | |
| Images in cards | |
| Modals |
Conversations
| Feature | Supported |
|---|---|
| Slash commands | Prefix-parsed |
| Mentions | |
| Add reactions | |
| Remove reactions | |
| Typing indicator | |
| Mark as read | |
| Message edit events | |
| Message delete events | |
| DMs | |
| Ephemeral messages | |
| User lookup | |
| Parent subject | |
| Native client | |
| Custom API endpoint | baseURL |
Message history
| Feature | Supported |
|---|---|
| Fetch messages | |
| Fetch single message | |
| Fetch thread info | |
| Fetch channel messages | |
| List threads | |
| Fetch channel info | |
| Post channel message |