OpenClaw Matrix Channel
Connect OpenClaw to Matrix — an open, federated communication protocol. This integration lets your AI assistant participate in Matrix rooms and direct messages across any homeserver (matrix.org, Element, or self-hosted). OpenClaw connects via the Matrix Client-Server API with optional end-to-end encryption (E2EE) support through the Rust crypto SDK. The Matrix channel ships as a plugin and supports federation, threads, reactions, and rich media.
Matrix Supported Features
Text Messages
Supported
Media & Files
Supported
Reactions
Supported
Threads
Supported
Voice Messages
Not Supported
Group Chat
Supported
Matrix Prerequisites
- An active Matrix account on any homeserver (matrix.org, Element, or self-hosted)
- The Matrix plugin installed: openclaw plugins install @openclaw/matrix
- OpenClaw Gateway running and configured
- Node.js 18+ installed on your server
Matrix Quick Setup
Install Matrix plugin
The Matrix channel ships as a separate plugin. Install it via 'openclaw plugins install @openclaw/matrix'. The plugin will be downloaded from the npm registry and enabled automatically.
Get Matrix credentials
You need either an access token or username/password. For access tokens: use curl to call your homeserver's login endpoint and copy the token. For username/password: the Gateway will automatically log in and store the token in ~/.openclaw/credentials/matrix/credentials.json.
Add Matrix channel config
Add the Matrix channel configuration to ~/.openclaw/openclaw.json with your homeserver URL and credentials. You can also use environment variables MATRIX_HOMESERVER, MATRIX_ACCESS_TOKEN, MATRIX_USER_ID, and MATRIX_PASSWORD.
Start Gateway and test
Run 'openclaw gateway' to start the service. Send a direct message to your Matrix bot user from another account. If using the default pairing policy, approve the sender via 'openclaw pairing approve matrix <code>' in your terminal.
Matrix Configuration Example
{
"channels": {
"matrix": {
"enabled": true,
"homeserver": "https://matrix.org",
"accessToken": "your_access_token_here",
"dmPolicy": "pairing"
}
}
}
Matrix Deep Dive
Architecture Overview
Authentication Methods
# Access token method
{
"channels": {
"matrix": {
"homeserver": "https://matrix.example.org",
"accessToken": "syt_xxx..."
}
}
}
# Username/password method
{
"channels": {
"matrix": {
"homeserver": "https://matrix.example.org",
"userId": "@bot:example.org",
"password": "your_password"
}
}
}
DM Policies
{
"channels": {
"matrix": {
"dmPolicy": "allowlist",
"dm": {
"allowFrom": ["@alice:matrix.org", "@bob:example.org"]
}
}
}
}
Group Chat (Room) Support
{
"channels": {
"matrix": {
"groupPolicy": "allowlist",
"groups": {
"!abc123:matrix.org": {
"allow": true,
"requireMention": false,
"users": ["@alice:matrix.org"]
},
"#team-chat:example.org": {
"allow": true
}
},
"autoJoin": "allowlist"
}
}
}
End-to-End Encryption (E2EE)
{
"channels": {
"matrix": {
"encryption": true
}
}
}
Federation & Homeserver Selection
Threading & Reply Modes
{
"channels": {
"matrix": {
"threadReplies": "always",
"replyToMode": "reference"
}
}
}
Media Handling & File Uploads
{
"channels": {
"matrix": {
"mediaMaxMb": 50
}
}
}
Reactions & Rich Features
{
"channels": {
"matrix": {
"actions": {
"reactions": true,
"messages": true,
"pins": false
}
}
}
}
Why Matrix for Self-Hosted AI?
Matrix Configuration Reference
| Key | Type | Default | Description |
|---|---|---|---|
| enabled | boolean | true | Enable or disable the Matrix channel |
| homeserver | string | "https://matrix.org" | Matrix homeserver URL (e.g., https://matrix.org, https://element.io) |
| accessToken | string | "" | Matrix access token for authentication (recommended method) |
| userId | string | "" | Matrix user ID (e.g., @bot:matrix.org) — used with password auth |
| password | string | "" | Matrix account password — used with userId for login |
| encryption | boolean | false | Enable end-to-end encryption via Rust crypto SDK |
| dmPolicy | string | "pairing" | DM access policy: pairing, allowlist, open, or disabled |
| dm.allowFrom | array | [] | Allowed Matrix user IDs for DMs (e.g., [@alice:matrix.org]) |
| groupPolicy | string | "allowlist" | Room policy: allowlist or disabled |
| groups | object | {} | Room-specific configuration (room ID or alias as key) |
| groups.<roomId>.allow | boolean | false | Allow bot to participate in this room |
| groups.<roomId>.requireMention | boolean | true | Require bot mention to trigger responses in this room |
| groups.<roomId>.users | array | [] | Per-room user allowlist (Matrix user IDs) |
| autoJoin | string | "allowlist" | Auto-join room invites: always, allowlist, or off |
| textChunkLimit | number | 4096 | Maximum characters per outbound message |
| chunkMode | string | "length" | How to split long responses: length (hard limit) or newline (paragraph boundaries) |
| threadReplies | string | "inbound" | Thread behavior: off, inbound (read only), or always (read + create) |
| replyToMode | string | "reference" | Reply metadata attachment mode |
| mediaMaxMb | number | 50 | Maximum media file size in megabytes |
| actions.reactions | boolean | true | Allow the agent to send/read reactions |
| actions.messages | boolean | true | Allow the agent to read/send/edit/delete messages |
| actions.pins | boolean | true | Allow the agent to pin/unpin messages |
| actions.memberInfo | boolean | true | Allow the agent to look up room member information |
| actions.channelInfo | boolean | true | Allow the agent to retrieve room/channel information |
Enable or disable the Matrix channel
Matrix homeserver URL (e.g., https://matrix.org, https://element.io)
Matrix access token for authentication (recommended method)
Matrix user ID (e.g., @bot:matrix.org) — used with password auth
Matrix account password — used with userId for login
Enable end-to-end encryption via Rust crypto SDK
DM access policy: pairing, allowlist, open, or disabled
Allowed Matrix user IDs for DMs (e.g., [@alice:matrix.org])
Room policy: allowlist or disabled
Room-specific configuration (room ID or alias as key)
Allow bot to participate in this room
Require bot mention to trigger responses in this room
Per-room user allowlist (Matrix user IDs)
Auto-join room invites: always, allowlist, or off
Maximum characters per outbound message
How to split long responses: length (hard limit) or newline (paragraph boundaries)
Thread behavior: off, inbound (read only), or always (read + create)
Reply metadata attachment mode
Maximum media file size in megabytes
Allow the agent to send/read reactions
Allow the agent to read/send/edit/delete messages
Allow the agent to pin/unpin messages
Allow the agent to look up room member information
Allow the agent to retrieve room/channel information
Matrix Frequently Asked Questions
Matrix Troubleshooting
DM policy blocking messages, or bot not in room
Device not verified or crypto modules failed to load
Token was revoked or invalidated on the homeserver
Room not in allowlist or requireMention is enabled
Homeserver connectivity or federation issues
npm registry access or Node.js version incompatibility