Matrix messaging integration plugin for elizaOS agents
Project description
@elizaos/plugin-matrix
Matrix messaging integration plugin for elizaOS agents.
Features
- 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
Installation
npm install @elizaos/plugin-matrix
Prerequisites
- Matrix Account: A Matrix account on any homeserver
- Access Token: Generate an access token for your account
Getting an Access Token
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
Configuration
Set the following environment variables:
Required
| 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 |
Optional
| 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 |
Usage
Basic Setup
import matrixPlugin from "@elizaos/plugin-matrix";
const agent = new Agent({
plugins: [matrixPlugin],
});
Actions
MATRIX_SEND_MESSAGE
Send a message to a Matrix room.
// User: "Send a message saying 'Hello everyone!'"
// Agent will send to the current room
MATRIX_SEND_REACTION
React to a message with an emoji.
// User: "React to the last message with 👍"
// Agent will add the reaction
MATRIX_LIST_ROOMS
List all rooms the bot has joined.
// User: "What rooms are you in?"
// Agent will list all joined rooms
MATRIX_JOIN_ROOM
Join a Matrix room by ID or alias.
// User: "Join #general:matrix.org"
// Agent will join the room
Providers
matrixRoomState
Provides context about the current Matrix room:
- Room ID and name
- Member count
- Encryption status
- Whether it's a DM
matrixUserContext
Provides context about the user in the conversation:
- User ID
- Display name
- Avatar URL
Events
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 |
Message Limits
- Maximum message length: 4000 characters
- Longer messages are split automatically
Matrix ID Formats
- User ID:
@localpart:homeserver.org - Room ID:
!opaque_id:homeserver.org - Room Alias:
#human_readable:homeserver.org
Security Considerations
- 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
Troubleshooting
Connection Issues
- Verify your homeserver URL is correct
- Check that your access token is valid
- Ensure your homeserver is reachable
Sync Issues
- The initial sync may take time for accounts with many rooms
- Check homeserver rate limits
- Verify network connectivity
Encryption Issues
- Ensure E2EE is enabled on both ends
- Verify device is properly set up
- Check for key verification requirements
Multi-language Support
This plugin supports:
- TypeScript - Full implementation with matrix-js-sdk
- Python - Full implementation with matrix-nio
- Rust - Full implementation with matrix-sdk
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elizaos_plugin_matrix-2.0.0a5.tar.gz.
File metadata
- Download URL: elizaos_plugin_matrix-2.0.0a5.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ddd8023bf5e8f17dfc625dfecf7d97e577a00841b4141cc5b01cdd0225e86b
|
|
| MD5 |
b7c4e7d50bc6819c62c9c1a312c80db3
|
|
| BLAKE2b-256 |
3acef844b1e3851f5d1f7236aeb062988a92c7ad8059980cb3a7dfe772301b4a
|
File details
Details for the file elizaos_plugin_matrix-2.0.0a5-py3-none-any.whl.
File metadata
- Download URL: elizaos_plugin_matrix-2.0.0a5-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49531ed0c0c10d4fa9006e8975a2dd50c921e723c8bfef3d06bab6b87bdde6bf
|
|
| MD5 |
eb744ec501108e3aba0dd48096aa61f1
|
|
| BLAKE2b-256 |
68aa4769c5bc06f4268a43cb7541a566b946aaf386d29bdaa72f92d9cd48f33e
|