Team Chat (Tuwunel)
Chat in the openSME suite is a Matrix homeserver — since December 2026 Tuwunel (Rust, embedded RocksDB), which replaced the previous Synapse deployment. For users nothing changed: Element Web is the interface, rooms and messages behave the same. This page covers both perspectives.
For users
You reach the chat client at the configured CHAT_DOMAIN of your
deployment (fleet default: chat.home.<domain> — it serves Element Web). The
login screen already shows the configured homeserver — you never type it.
-
Sign in with the account your administrator created (username + password). Accounts are created with the tenant's registration token: anyone holding it can sign themselves up, and the first account on a fresh server becomes the admin.
-
The shared room. Every deployment starts with one public room (
#support) — it appears in your room list when you join. -
Talk to the assistant bot. The openSME intercom bot serves the shared room via the suite's model gateway:
Command Effect !ai <question>answers through the configured model !entwurf <text>drafts an email/message reply !briefdaily digest of the room
For operators
All wiring lives in services/tuwunel.yml of the compose chain. The compose
service is still keyed synapse deliberately — the API broker, Element and
every internal consumer dial http://synapse:8008, and at docker ps level
the container is honestly named opensme-tuwunel.
The knobs
| Variable | Meaning |
|---|---|
MATRIX_DOMAIN | the single chat-host knob: server_name and the router's Host rule derive from it identically (default matrix.home.<apex>). Tuwunel freezes the server name into the database at first boot — changing it later means a fresh store |
CHAT_REGISTRATION_TOKEN | required by /register; mint with openssl rand -hex 16 |
TUWUNEL_APPSERVICE_DIR | read-only directory of appservice registrations (services/tuwunel.d/); empty means none — opt-in by deployment |
TUWUNEL_RATE_LIMITING__LOGIN__ACCOUNT__* | token bucket on successful sign-ins; the overlay raises it (10 burst, one per ~50 s) because a self-healing bot starves itself with 429s otherwise — wrong passwords never count on this axis |
TUWUNEL_CONFIG | points at services/tuwunel.config/oidc.toml — the identity-provider layer (rendered per deployment, mode 0600, userid_claims = ["email", "sub"] so accounts derive from the email claim via userinfo). Env selection, not a -c argument: the image's health probe only sees config passed through the environment |
The broker appservice
The suite's API broker authenticates as a
Matrix application service: it creates _broker* virtual users and posts
as them without passwords. The registration file (rendered per deployment,
mode 0600) sets url: null — the broker only calls the client API, the
homeserver never pushes. Two strict lessons from cutover day: a missing
url field aborts the whole appservice loader with only a log line, and the
AS token is deliberately the same secret the broker already holds
(INTERCOM_BROKER_MATRIX_AS_SECRET) — one secret, no second source.
Bootstrap (fresh server)
CHAT_URL=https://matrix.home.example.org \
CHAT_REGISTRATION_TOKEN=… MATRIX_PASSWORD=… \
python3 scripts/chat-bootstrap.py
Idempotent: registers the bot user (testuser), logs in, creates #support
unless a room already exists. Stdlib-only Python — no jq, no curl needed
on the host.
What the Synapse cutover changed
| Before | Now | Why |
|---|---|---|
| Python + PostgreSQL + gunicorn | single Rust binary + RocksDB | one moving part less; chat no longer shares the suite's Postgres |
| login limits counted failures | limits count successful sign-ins per account | bots may restart; brute force is protected by failure caps elsewhere |
| lax query strings tolerated | sync filter JSON must be percent-encoded | strictness caught a latent bot bug the same day |
| Zitadel OIDC login | Zitadel OIDC login, again | re-implemented as [[global.identity_provider]] — but the callback route is /_tuwunel/sso/callback/<client_id>; the provider pins callback_url to the static segment …/zitadel to break the client_id ⇄ redirect-list chicken-and-egg |
/_synapse/admin REST | the admin room (!admin …) | no HTTP admin surface to secure |
The old synapse_db stays on the database server as an offline backup; drop
it when the chat-history retention window ends.
Verifying
The runtime journey tests/05-e2e/tuwunel_chat.py walks the promise against a
live server (discovery, wrong-token rejection, throwaway signup, whoami, room
create, message → sync round trip, the appservice chapter: virtual-user
registration, self-owned room, login-free posting; and with
CHAT_EXPECT_OIDC=1 the SSO chapter: /login advertises m.login.sso and the
redirect lands on the IdP authorize endpoint with PKCE). The Layer-0 contract
tests/00-static/check_chat_tuwunel.py guards the cutover decisions
themselves — version-pinned image, single domain knob, read-only appservice
mount, blackbox probe coherence.