Files
Hermes_rocket.chat_Plugin/README.md
T

116 lines
4.5 KiB
Markdown

# Hermes Rocket.Chat Plugin
> Bidirectional real-time messaging between Hermes Agent and self-hosted Rocket.Chat servers.
> Zero external dependencies — uses WebSocket/DDP + REST API.
**⚠️ Community Add-on — not an official Nous Research product.**
This plugin is maintained independently. Use at your own risk. See [LICENSE](LICENSE).
## Features
- 🟢 **Real-time messaging** via DDP/WebSocket (`stream-room-messages`)
- 💬 **Interactive buttons** — Native Rocket.Chat attachments with `question_id::choice` correlation
- 🔌 **7 REST tools** — `rocketchat_rooms`, `rocketchat_users`, `rocketchat_dm`, `rocketchat_send`, `rocketchat_upload`, `rocketchat_download`, `rocketchat_files`
- 🧭 **Smart Room Routing** — Automatically learns which topics belong in which rooms. Keeps conversations organized across channels, groups, and DMs. One agent, many rooms, zero confusion.
- 📎 **File Attachments** — Upload, download, and list files with native Rocket.Chat rendering
- 🌐 **Multi-Room Presence** — One agent session across all rooms. Shared context, clean delivery.
- 🟢 **Online presence** — Green dot via DDP `UserPresence`
- ♻️ **Auto-reconnect** with exponential backoff
- 🌍 **Bilingual installer** — German & English (`--lang de|en`)
## Quick Install
```bash
git clone https://gitea.myowntools.org/andreas/Hermes_rocket.chat_Plugin.git
cd Hermes_rocket.chat_Plugin
./install.sh
```
The installer will ask for:
- Rocket.Chat server URL
- Bot username (the bot account on your Rocket.Chat server)
- Bot password
- Home channel (name or room ID)
**After installation:** The gateway will output a pairing code — enter it in your home channel to activate the bot.
### Options
```
./install.sh --help # Show all options
./install.sh --lang en # English
./install.sh --lang de # German (default)
./install.sh --non-interactive # Batch mode (reads from env vars)
```
## Architecture
```
Rocket.Chat Server
↕ WebSocket/DDP + REST
Hermes Gateway (plugin)
↕
Hermes Agent ← → LLM inference
```
The plugin registers as `rocketchat-platform` in Hermes' bundled plugin path (`hermes-agent/plugins/platforms/rocketchat/`).
## Interactive Buttons
The plugin supports native Rocket.Chat buttons. The agent sends them via `send_message` with metadata:
```python
send_message(
target="rocketchat:protonbridge",
text="Proceed?",
metadata={
"template": "custom",
"question_id": "confirm_42",
"button_title": "Choose:",
"custom_buttons": ["✅ Yes", "❌ No"]
}
)
```
User click returns: `confirm_42::✅ Yes`
**Button label rules:**
- Max ~7 visible characters on desktop (mobile shows full text)
- **NO underscores** — breaks Rocket.Chat rendering
- Spaces allowed: `1. Left`, `2. Right`
- Prefix with number/keyword for distinguishability
See [docs/BUTTON_GUIDE.md](docs/BUTTON_GUIDE.md) for full details.
## Environment Variables
Set in `~/.config/hermes/rocketchat.env` (generated by install.sh):
```bash
ROCKETCHAT_BASE_URL=https://rocketchat.example.com
ROCKETCHAT_USER=botuser
ROCKETCHAT_PASSWORD=...
ROCKETCHAT_ROOM_NAME=ki-assistent
ROCKETCHAT_ALLOW_ALL_USERS=true
GATEWAY_ALLOW_ALL_USERS=true
```
## Requirements
- Hermes Agent installed
- Self-hosted Rocket.Chat server (V5+)
- Bot user account on the Rocket.Chat server
- Python 3.10+ (hermes-agent venv)
## Troubleshooting
| Symptom | Cause | Fix |
|---------|-------|-----|
| `No module named 'hermes_plugins.rocketchat_platform.tools'` | `__init__.py` has hard `from .tools import register_tools` but `tools.py` missing | Wrap import in `try/except ImportError` and guard `register_tools(ctx)` call |
| `Failed to load plugin 'rocketchat-platform': No module named 'archivar'` | Plugin submodule uses **absolute imports** (`from archivar.X import Y`) — these only work when the module is on global `sys.path`, not in Hermes' Plugin-Loader context | **All imports within the plugin package MUST be relative.** Rule: `from archivar.X` → `from .X` (inside submodule), `from archivar.X` → `from .archivar.X` (from `adapter.py`). Affects ALL `.py` files in the submodule. 2026-06-03: 11 imports in 5 files affected |
| Gateway shows `No adapter available for rocketchat`, only Telegram active | Plugin loading failed silently — check `errors.log` for the exact import error | Fix the import, then `systemctl --user restart hermes-gateway`. Verify: `journalctl --user -u hermes-gateway | grep "Subscribed to"` |
## License
[Unlicense](LICENSE) — Public Domain. See [LICENSE](LICENSE).