Bots & Integrations
Extend Matrix with bots for moderation, automation, notifications, and more.
Types of Bots
Simple Bots
Basic bots that respond to commands:
- Echo bots, reminder bots
- Info bots, help bots
- Simple automation
Appservice Bots
More powerful bots using the Application Service API:
- Can create users/rooms
- Higher rate limits
- Background processing
Moderation Bots
Keep communities safe:
- Mjolnir - Ban lists, spam protection
- Draupnir - Mjolnir fork with improvements
Integration Bots
Connect external services:
- Hookshot - GitHub, GitLab, JIRA
- Maubot - Plugin-based bot system
Popular Bot Frameworks
| Framework | Language | Complexity | Best For |
|---|---|---|---|
| Maubot | Python | Medium | Plugin ecosystem |
| matrix-bot-sdk | TypeScript | Low | Quick bots |
| mautrix | Python | Low | Simple bots |
| matrix-nio | Python | Low | Async bots |
| matrix-rust-sdk | Rust | Medium | Performance |
Quick Start: Simple Bot
Using matrix-nio (Python):
from nio import AsyncClient, RoomMessageText
async def message_callback(room, event):
if event.body.startswith("!hello"):
await client.room_send(
room.room_id,
"m.room.message",
{"msgtype": "m.text", "body": "Hello, World!"}
)
client = AsyncClient("https://matrix.example.com", "@bot:example.com")
await client.login("password")
client.add_event_callback(message_callback, RoomMessageText)
await client.sync_forever()
Integration Services
Hookshot
Connect Matrix to development tools:
- GitHub: Issues, PRs, commits
- GitLab: Issues, MRs, pipelines
- JIRA: Issues, projects
- Generic webhooks
- RSS feeds
Dimension
Integration manager for Matrix:
- Widget management
- Sticker packs
- Bot configuration
- Bridge management
NEB (Legacy)
Older integration bot:
- RSS feeds
- Service notifications
- Being replaced by Hookshot
Hosted Bot Services
| Service | Bots Included | Notes |
|---|---|---|
| t2bot.io | Many | Free, public |
| Element EMS | Enterprise | Managed |
| etke.cc | Various | Managed hosting |
t2bot.io Public Bots
Free bots anyone can use:
@echo:t2bot.io- Echo bot@rss:t2bot.io- RSS feeds@reminder:t2bot.io- Reminders@giphy:t2bot.io- GIF search
Invite to any room to use.
Bot Security
Best Practices
- Minimal permissions - Only request needed power levels
- Validate input - Sanitize all user input
- Rate limiting - Prevent abuse
- Audit logging - Track bot actions
- Secure tokens - Never expose access tokens
Power Levels for Bots
| Purpose | Suggested Level |
|---|---|
| Read-only bot | 0 (default) |
| Posting bot | 0 (default) |
| Moderation bot | 50+ |
| Admin bot | 100 |
Building vs Using
Use Existing Bots When
- Standard functionality needed
- Quick deployment required
- Don't want to maintain code
Build Custom Bots When
- Unique requirements
- Integration with internal systems
- Learning/experimentation
Getting Started
- Maubot - Most versatile, plugin-based
- Mjolnir - Essential for moderation
- Hookshot - GitHub/GitLab integration
- Building Bots - Create your own