Features
- ✅ End-to-end encryption (E2EE) support
- ✅ Matrix homeserver compatibility
- ✅ User ID-based access control
- ✅ Group chat with configurable policies
- ✅ Media attachment support with size limits
- ✅ Room mention handling
Prerequisites
Install Matrix dependencies:Setup
Create or choose Matrix account
- Create a dedicated Matrix account for your bot
- You can use any homeserver (e.g.,
matrix.org, or your own) - Example:
@nanobot:matrix.org - Confirm you can log in with Element client
Get credentials
You need three pieces of information:
- userId: Your Matrix user ID (e.g.,
@nanobot:matrix.org) - accessToken: Authentication token
- deviceId: Device identifier (recommended for session persistence)
- Log in to Element Web
- Settings → Help & About
- Scroll to bottom → Access Token
- Click to reveal token (starts with
syt_)
Get your User ID
Your Matrix user ID is shown in Element settings:
- Open Element
- Click your profile
- Copy your User ID (format:
@youruser:matrix.org)
Configuration Options
Enable the Matrix channel
Matrix homeserver URLExamples:
https://matrix.orghttps://your-homeserver.com
Matrix user ID for the bot (format:
@username:homeserver)Access token for authentication (format:
syt_xxx)Device identifier (recommended for session persistence)
Keep a persistent
matrix-store and stable deviceId — encrypted session state is lost if these change across restarts.Enable end-to-end encryption supportSet to
false for plaintext-only mode (not recommended).List of Matrix user IDs allowed to interact with the botExamples:
- Single user:
["@alice:matrix.org"] - Multiple:
["@alice:matrix.org", "@bob:matrix.org"] - All users:
[](empty array)
Controls how the bot responds in rooms:
"open"(default) — Respond to all messages"mention"— Only respond when mentioned"allowlist"— Only respond in specific rooms
Room IDs to allow (used when
groupPolicy is "allowlist")Example: ["!roomid1:matrix.org", "!roomid2:matrix.org"]Accept
@room mentions in mention modeIf true, bot responds to @room mentions in addition to direct mentions.Maximum attachment size in bytes (default: 20MB)Set to
0 to block all media uploads.End-to-End Encryption
Understanding E2EE in Matrix
Understanding E2EE in Matrix
Matrix supports end-to-end encryption for secure messaging.
Enabled by default
- Bot can send/receive encrypted messages
- Requires
matrix-storefor session state - Supports device verification
Plaintext only
- Bot only works in unencrypted rooms
- Simpler setup, no encryption overhead
- Not recommended for sensitive conversations
Important notes
- Keep
deviceIdstable across restarts - Keep
matrix-storedirectory persistent - Lost encryption state = can’t decrypt old messages
- Verify devices in Element for trusted communication
Group Chat Policies
Configuring group chat behavior
Configuring group chat behavior
Troubleshooting
Matrix dependencies not installed
Matrix dependencies not installed
Error:
ModuleNotFoundError: No module named 'nio'Solution: Install Matrix dependenciesBot doesn't respond
Bot doesn't respond
- Check user ID is in
allowFrom(or use empty array for all) - Check
groupPolicysettings for room behavior - Verify access token is valid
- Check homeserver is reachable
- Look for errors in logs:
nanobot gateway -v
Encryption errors
Encryption errors
If you see encryption-related errors:
- Lost session state:
- Check
matrix-storedirectory exists and is writable - Ensure
deviceIdhasn’t changed - May need to re-verify device in Element
- Check
- Unable to decrypt:
- Verify bot account in Element
- Check E2EE is enabled:
"e2eeEnabled": true - Clear encryption state and restart
- Start fresh:
Then re-verify device in Element.
Connection to homeserver fails
Connection to homeserver fails
- Verify
homeserverURL is correct (includehttps://) - Check homeserver is online and accessible
- Verify access token is valid (not expired/revoked)
- Check firewall allows outbound HTTPS
- Try alternative homeserver if using matrix.org (can be slow)
Media uploads fail
Media uploads fail
- Check file size is under
maxMediaByteslimit - Verify homeserver allows media uploads
- Check bot has permission to upload to room
- Increase limit if needed:
(50MB in bytes)
Bot appears offline
Bot appears offline
- Verify gateway is running:
nanobot gateway - Check access token hasn’t expired
- Verify homeserver status
- Check network connectivity
- Try logging out and back in to get new token
Complete Example
Full configuration with all options:Related Pages
Configuration Overview
Learn about channel configuration
Security Settings
Set up access control