Skip to main content
The Matrix channel enables communication through the Matrix protocol with support for encrypted rooms.

Overview

Matrix is a decentralized, encrypted communication protocol used by:
  • Element (official client)
  • Government organizations
  • Privacy-focused communities
  • Federated chat systems
Features:
  • End-to-end encryption (E2EE)
  • Decentralized architecture
  • Room-based messaging
  • User allowlists
  • Mention-only mode

Configuration

Basic Setup

With Allowlist

Getting Access Token

1

Create Matrix Account

Sign up at https://app.element.io or your homeserver
2

Get Access Token

Element Web:
  1. Settings → Help & About
  2. Scroll to “Advanced”
  3. Click “Access Token”
  4. Copy the token
3

Find Room ID

Element Web:
  1. Open room
  2. Room settings → Advanced
  3. Copy “Internal room ID” (e.g., !abc123:matrix.org)
Or use room alias: #roomname:matrix.org

Features

End-to-End Encryption

Matrix channel automatically handles E2EE rooms using the matrix-sdk library:
First message in encrypted room may take a few seconds while keys are exchanged.

Session Persistence

Matrix sessions are stored in ~/.zeroclaw/matrix/ directory:
  • Crypto store: Encryption keys
  • Session data: Login session
  • State sync: Room membership

Mention-Only Mode

Only respond when bot is mentioned:
Agent only replies to messages containing mention like:

User Allowlist

Restrict who can interact:
Messages from other users are ignored.

Room Types

Public Rooms

Private Rooms

Encrypted Rooms

Message Features

Send Messages

Receive Messages

Automatically processes:
  • Text messages
  • Encrypted messages (auto-decrypted)
  • Mentions
  • Room invites

Implementation Details

Matrix SDK:
  • Uses matrix-sdk crate
  • Full E2EE support via Olm/Megolm
  • Automatic key backup
  • Device verification
Sync Mode:
  • Long-polling sync
  • Real-time message delivery
  • Encrypted room support
  • Automatic reconnection
Source: src/channels/matrix.rs

Troubleshooting

Solutions:
  1. Delete crypto store and re-login:
  1. Verify bot has been invited to encrypted room
  2. Check logs for key exchange errors:
Solutions:
  1. Check allowlist:
  1. Verify room ID format:
  1. Check mention_only mode:
Solutions:
  1. Verify homeserver URL:
  1. Check access token validity:
  1. Test with fresh token

Performance

Sync Latency:
  • Real-time: <1 second (long-polling)
  • Encrypted rooms: +500ms (decryption overhead)
Message Throughput:
  • Send: 10 messages/second
  • Receive: Limited by sync rate

Security

  • E2EE: All messages in encrypted rooms use Olm/Megolm
  • Access Control: User allowlists enforced
  • Token Storage: Access token stored in config (use environment variable in production)
  • Device Trust: Automatic device verification
Best practices: