Matrix messaging integration plugin for ElizaOS agents.
- Decentralized Messaging: Connect to any Matrix homeserver
- End-to-End Encryption: Optional E2EE support for secure communications
- Room Support: Join, leave, and manage Matrix rooms
- Reactions: React to messages with emoji
- Threading: Support for Matrix threads
- Direct Messages: Handle DMs and group rooms
- Typing Indicators: Send typing notifications
- Read Receipts: Mark messages as read
npm install @elizaos/plugin-matrix- Matrix Account: A Matrix account on any homeserver
- Access Token: Generate an access token for your account
You can get an access token by:
- Element/Web Client: Settings -> Help & About -> Access Token
- API Login: Use the Matrix login API with your password
- Command Line: Use
curlor a tool likematrix-commander
Set the following environment variables:
| Variable | Description |
|---|---|
MATRIX_HOMESERVER |
Homeserver URL (e.g., https://matrix.org) |
MATRIX_USER_ID |
Full Matrix user ID (@user:homeserver.org) |
MATRIX_ACCESS_TOKEN |
Access token for authentication |
| Variable | Description | Default |
|---|---|---|
MATRIX_DEVICE_ID |
Device ID for this session | Auto-generated |
MATRIX_ROOMS |
Comma-separated room IDs/aliases to auto-join | - |
MATRIX_AUTO_JOIN |
Auto-accept room invites | false |
MATRIX_ENCRYPTION |
Enable E2EE support | false |
MATRIX_REQUIRE_MENTION |
Only respond when mentioned in rooms | false |
import matrixPlugin from "@elizaos/plugin-matrix";
const agent = new Agent({
plugins: [matrixPlugin],
});Send a message to a Matrix room.
// User: "Send a message saying 'Hello everyone!'"
// Agent will send to the current roomReact to a message with an emoji.
// User: "React to the last message with 👍"
// Agent will add the reactionList all rooms the bot has joined.
// User: "What rooms are you in?"
// Agent will list all joined roomsJoin a Matrix room by ID or alias.
// User: "Join #general:matrix.org"
// Agent will join the roomProvides context about the current Matrix room:
- Room ID and name
- Member count
- Encryption status
- Whether it's a DM
Provides context about the user in the conversation:
- User ID
- Display name
- Avatar URL
The plugin emits the following events:
| Event | Description |
|---|---|
MATRIX_MESSAGE_RECEIVED |
A message was received |
MATRIX_MESSAGE_SENT |
A message was sent |
MATRIX_ROOM_JOINED |
Joined a room |
MATRIX_ROOM_LEFT |
Left a room |
MATRIX_INVITE_RECEIVED |
Received a room invite |
MATRIX_REACTION_RECEIVED |
Received a reaction |
MATRIX_SYNC_COMPLETE |
Initial sync completed |
MATRIX_CONNECTION_READY |
Client connected |
MATRIX_CONNECTION_LOST |
Connection lost |
- Maximum message length: 4000 characters
- Longer messages are split automatically
- User ID:
@localpart:homeserver.org - Room ID:
!opaque_id:homeserver.org - Room Alias:
#human_readable:homeserver.org
- Token Security: Never expose your access token
- Homeserver Trust: Only connect to trusted homeservers
- E2EE: Enable encryption for sensitive communications
- Room Verification: Verify room members when using E2EE
- Verify your homeserver URL is correct
- Check that your access token is valid
- Ensure your homeserver is reachable
- The initial sync may take time for accounts with many rooms
- Check homeserver rate limits
- Verify network connectivity
- Ensure E2EE is enabled on both ends
- Verify device is properly set up
- Check for key verification requirements
This plugin supports:
- TypeScript - Full implementation with matrix-js-sdk
- Python - Full implementation with matrix-nio
- Rust - Full implementation with matrix-sdk
MIT