Matrix
Matrix Channel
Section titled “Matrix Channel”Human can send messages to Matrix rooms and receive messages via polling. Works with matrix.org or self-hosted Synapse homeservers.
Prerequisites
Section titled “Prerequisites”- Build with
-DHU_ENABLE_MATRIX=ONor-DHU_ENABLE_ALL_CHANNELS=ON - libcurl / HTTP client support
- A Matrix account and access token
- Room ID (or room alias) to send/receive in
Configuration
Section titled “Configuration”Add to ~/.human/config.json. Matrix expects a channels.matrix array of account configs:
{ "channels": { "matrix": [ { "homeserver": "https://matrix.org", "access_token": "syt_...", "room_id": "!abc123:matrix.org", "allow_from": [] } ] }}Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
homeserver | string | Base URL of the Matrix homeserver (no trailing slash) |
access_token | string | Bearer token for API authentication |
room_id | string | Room ID (e.g. !xxx:matrix.org) or alias |
allow_from | array | User IDs to allow. Empty = allow all |
Getting an access token
Section titled “Getting an access token”- Use a client (Element, etc.) or matrix.org/login to log in
- Use a script or client API to obtain an access token, or use tools like matrix-cli
- Store the token in config (keep it secret)
Room ID
Section titled “Room ID”- Room IDs start with
!(e.g.!abc123:matrix.org) - Room aliases start with
#(e.g.#room:matrix.org) — resolve to room ID via API if needed
How it works
Section titled “How it works”Outbound (send)
Section titled “Outbound (send)”- Sends
PUT /_matrix/client/r0/rooms/<room_id>/send/m.room.message/<txn_id> - Payload:
{"msgtype":"m.text","body":"<message>"} - Uses
Authorization: Bearer <access_token> - Transaction ID is derived from
time(NULL)for idempotency
Inbound (receive)
Section titled “Inbound (receive)”- Polling-based (poll interval: 2000 ms)
- Uses Matrix Client-Server API to sync or poll for new messages
- Fetches events from the room; filters for
m.room.messagefrom other users allow_fromrestricts which user IDs the bot responds to
Platform limitations
Section titled “Platform limitations”- Polling only: No Synapse push/WebSocket in this implementation; uses periodic sync
- Plain text: Sends
m.textonly; no rich formatting or media - Single room per config: Each config entry targets one room