Connecting OpenClaw AI Agents to Matrix - Setup and Configuration Guide
Deploy OpenClaw for Your Business
Secure deployment in 48 hours. Choose personal setup or fully managed.
Most of the messaging platforms we deploy AI agents to are centralised. Slack, Teams, WhatsApp - they all run on servers owned by a single company, and your data lives wherever that company decides to put it. For a lot of businesses, that's fine. But for governments, universities, defence contractors, and organisations with strict data sovereignty requirements, it's a problem. That's where Matrix comes in.
Matrix is an open, decentralised communication protocol. Think of it like email but for real-time messaging - anyone can run their own server, and servers federate with each other so users on different servers can still communicate. The Australian government uses it. French government agencies use it. NATO uses it. The open-source community has largely adopted it. When these organisations want AI agents in their communication channels, they're not asking for a Slack bot. They're asking for something that works on Matrix.
OpenClaw's Matrix channel adapter connects your AI agent to the Matrix protocol using the official matrix-js-sdk. It supports DMs, rooms, threads, media, reactions, polls, location sharing, and - this is the big one - end-to-end encryption. I've been setting these up for clients who need their AI agents operating inside encrypted, self-hosted communication infrastructure, and the experience has been genuinely good. Not perfect, but good.
The official OpenClaw Matrix documentation has the full configuration reference. Here's what it actually looks like to get this running.
Installing the Matrix Plugin
Unlike some of OpenClaw's built-in channels, Matrix is a plugin. You install it separately:
openclaw plugins install @openclaw/matrix
This pulls in the matrix-js-sdk and the Rust crypto SDK that handles encryption. The plugin architecture means the Matrix support gets updated independently from the core OpenClaw release cycle, which is nice - Matrix protocol updates don't have to wait for a full OpenClaw release.
Once installed, you configure it like any other channel in your OpenClaw config.
What You Need Before Starting
You need a Matrix account for your bot. This means either creating an account on a public homeserver (like matrix.org) or, more likely for the use cases where Matrix makes sense, creating an account on your organisation's own homeserver.
If your organisation runs Synapse (the reference Matrix homeserver), your admin can create a bot account through the admin API. If you're using Dendrite or Conduit, the process varies slightly but the end result is the same - you need a Matrix user ID and an access token.
The user ID will look something like @your-bot:your-domain.org. The access token is what OpenClaw uses to authenticate via the Matrix Client-Server API.
Basic Configuration
Here's the minimum to get your agent connected:
{
channels: {
matrix: {
enabled: true,
homeserverUrl: "https://matrix.your-domain.org",
userId: "@your-bot:your-domain.org",
accessToken: "your-access-token-here",
},
},
}
You can also use environment variables: MATRIX_HOMESERVER_URL, MATRIX_USER_ID, and MATRIX_ACCESS_TOKEN. Start the gateway with openclaw gateway and your bot should connect and sync with the homeserver.
First time setup takes a bit longer than Slack or Discord because you're likely dealing with self-hosted infrastructure. Budget extra time if your homeserver sits behind a VPN or requires certificate configuration.
End-to-End Encryption - The Real Reason You're Here
Let's be honest. If you just wanted a chat bot in a messaging app, you'd use Slack or Discord. The reason organisations choose Matrix is usually because they need E2EE, data sovereignty, or both. So the encryption story matters more here than in any other OpenClaw channel.
OpenClaw's Matrix adapter supports E2EE through the Rust crypto SDK, which implements the Olm and Megolm protocols. Olm handles the initial key exchange between devices (similar to Signal's Double Ratchet), and Megolm handles the group encryption for rooms with multiple participants.
What this means in practice: your AI agent can participate in encrypted rooms. Messages sent to the agent are encrypted on the sender's device and decrypted by the OpenClaw instance. Responses from the agent are encrypted before leaving the OpenClaw instance. At no point do unencrypted messages pass over the network. The homeserver only sees ciphertext.
Setting up E2EE requires a bit more work than an unencrypted deployment. The bot needs to complete device verification with other users in encrypted rooms. The first time the bot joins an encrypted room, there's a key exchange process. OpenClaw handles most of this automatically, but you may need to manually verify the bot's device from another client (like Element) the first time.
One honest caveat: E2EE with bots is still a bit awkward across the Matrix ecosystem, not just with OpenClaw. Device verification flows were designed for humans, and adapting them for automated agents requires some workarounds. It works, but the initial setup is less smooth than the unencrypted path. Once it's running, though, it's solid.
Room and DM Configuration
OpenClaw's access control model for Matrix mirrors what you'd expect from the other channel adapters.
Direct Messages
The dmPolicy setting controls who can DM your bot:
- pairing (default) - users complete a pairing flow before the bot responds. Good for controlled rollouts.
- allowlist - only specific Matrix user IDs can DM the bot.
- open - anyone who can reach your homeserver can message the bot.
- disabled - DMs turned off entirely.
For most deployments where the homeserver is self-hosted and access-controlled, open is actually reasonable because the homeserver itself acts as the access boundary. If you're running the bot on a public homeserver like matrix.org, pairing or allowlist is the safer choice.
Room Policies
The groupPolicy controls which rooms the bot participates in:
- open - the bot responds in any room it's invited to
- allowlist - only responds in rooms you've listed by room ID
- disabled - no room support
Deploy OpenClaw for Your Business
Secure deployment in 48 hours. Choose personal setup or fully managed.
For federated deployments - where the bot might be invited to rooms on other homeservers - I'd strongly recommend allowlist. Federation is one of Matrix's best features, but it also means anyone running a Matrix server could theoretically invite your bot to a room. Limit that surface area.
Room messages are mention-gated by default. The bot only responds when someone mentions it or replies in a thread it started. Same sensible default as the Slack and Discord adapters.
Per-Room Configuration
You can customise the agent's behaviour per room:
{
channels: {
matrix: {
channels: {
"!roomid:your-domain.org": {
requireMention: true,
users: ["@alice:your-domain.org", "@bob:your-domain.org"],
skills: ["research", "document-analysis"],
systemPrompt: "You are a research assistant for the policy team.",
},
"!otherroomid:your-domain.org": {
requireMention: false,
skills: ["ops", "monitoring"],
systemPrompt: "You are an operations assistant. Report status concisely.",
},
},
},
},
}
This pattern works well for organisations that use Matrix rooms the way others use Slack channels - different rooms for different teams and functions, each getting a tailored agent experience.
Commands in Matrix
OpenClaw's command system works in Matrix rooms and DMs. The available commands include:
/focusand/unfocus- direct the agent's attention to specific topics or contexts/agents- list available agents/session idleand/session max-age- control conversation session timeouts/acp spawn- spawn sub-agents within a thread
The thread-bound /acp spawn command is particularly useful in Matrix because Matrix has proper native thread support. You can spawn a specialist sub-agent in a thread and it stays contained there, handling that specific conversation without affecting the broader room.
Commands need to be enabled in your configuration, similar to how slash commands work in the Slack and Discord adapters.
Media and Rich Content
The Matrix adapter supports the full range of media types that Matrix rooms handle - images, files, audio, video. Your agent can receive documents, process them, and respond with formatted messages.
Reactions and polls are also supported. An agent can react to messages with emoji (useful for acknowledgments without cluttering the room with text) and create polls for gathering input from room participants. Location sharing works too, though the use cases for that with an AI agent are more niche.
Federation - The Feature That Changes Things
Here's what makes Matrix fundamentally different from deploying an agent on Slack or Discord. Because Matrix is federated, a single room can include participants from multiple organisations, each running their own homeserver.
Your AI agent sits on your homeserver. Users from partner organisations join the same room from their homeservers. The agent responds to everyone in the room, but the agent's processing, data, and configuration all stay on your infrastructure. No third party controls the communication channel.
For joint ventures, multi-agency government projects, or consortium setups, this is a real architectural advantage. Everyone keeps control of their own infrastructure while still collaborating in the same rooms with the same AI agent.
The practical gotcha with federation is latency. Messages between federated homeservers take longer than messages within a single homeserver. It's usually only a few hundred milliseconds, but it adds up in the round trip between a user sending a message, the bot receiving it, processing it, and sending a response back across federation. For most use cases this is fine. For anything time-sensitive, keep the bot and users on the same homeserver.
Clients and User Experience
Most users will interact with your bot through Element, the most popular Matrix client. Element runs on web, desktop, iOS, and Android. Because Matrix is an open protocol, there are dozens of other clients too - FluffyChat, Nheko, Hydrogen, SchildiChat. Your bot works with all of them because it operates at the protocol level, not the client level.
What Works Well, What's Still Rough
Works well: E2EE support is genuine and functional. Once set up, encrypted conversations with the agent work reliably. The per-room configuration gives you the flexibility you need for real deployments. Federation support means the bot participates in cross-organisation rooms without architectural gymnastics. Media handling covers most business use cases.
Still rough: Initial E2EE device verification is clunky for bot accounts. The Matrix ecosystem is smaller than Slack or Discord, so there are fewer community resources when you hit edge cases. Some Matrix homeserver implementations have quirks that affect bot behaviour - Synapse is the most battle-tested, but if your organisation runs a different homeserver, expect to spend time on compatibility testing. The plugin model means you're managing an extra dependency compared to built-in channels.
My honest take: Matrix is not the channel I'd recommend for an organisation that just wants to "try out AI agents." The setup complexity is higher than Slack or Telegram, and the user base in most Australian businesses is smaller. But for organisations that already use Matrix - or need to use it for compliance, sovereignty, or security reasons - the OpenClaw integration is well-built. It respects what makes Matrix different and doesn't try to paper over the protocol's unique characteristics.
Getting Started
At Team 400, we deploy OpenClaw agents across all supported channels for Australian organisations. Matrix deployments tend to be our more involved engagements because they usually come with E2EE requirements, self-hosted infrastructure, and cross-organisation federation needs.
If you're running Matrix and want to bring AI agents into your encrypted rooms, our OpenClaw managed service handles the full lifecycle - installation, configuration, encryption setup, monitoring, and ongoing tuning. For organisations thinking about where AI agents fit into their operations more broadly, Matrix is often one piece of a multi-channel strategy that might include Slack, Teams, or web chat alongside the Matrix deployment.
We also help organisations design and build custom agentic automations that use Matrix as the human-in-the-loop communication layer - agents that monitor systems, take autonomous action where appropriate, and escalate to humans in encrypted Matrix rooms when decisions need a person.
The full configuration reference is in the OpenClaw Matrix channel documentation.