---
title: "Chat and chat↔call integration"
description: "Matrix and Tuwunel, and how calls and chat are coupled."
---

![Chat and meet integration](/blume-assets/content/docs/architecture/diagrams/08-chat-meet-integration.png)

## Choice of chat server

The discussions explored two chat servers:

* **Rocket.Chat** per tenant (MongoDB; named in `AGENTS.md` and the EU-privacy
  discussion), and
* **Tuwunel**, a Rust Matrix homeserver (RocksDB embedded; Matrix discussion).

The design below uses **Tuwunel / Matrix** because the integration story with
go-meet (appservice bot, room-per-meeting, persistent in-call chat) is the most
developed, it has no extra database service per tenant, and Matrix is an open
protocol clients can reuse. This is recorded as **ADR-002** and flagged for
confirmation, since `AGENTS.md` still lists Rocket.Chat. If Rocket.Chat is
retained instead, everything in this document that is not Matrix-specific
(identity mapping, per-tenant isolation, bot posting from go-meet) still holds;
it would need MongoDB per tenant in the shard design.

## Per-tenant Matrix deployment

| Aspect | Decision |
|---|---|
| Instance | One Tuwunel per tenant, container in the tenant project |
| `server_name` | `<slug>.<platform-domain>` (user ids `@<zitadel-sub>:<slug>.<platform-domain>`) |
| Storage | RocksDB on a tenant volume; media on the volume (S3 offload optional) |
| Federation | **Disabled** (empty allowlist, no outbound server list); the privacy promise |
| Auth | OIDC with the tenant's Zitadel org via a Tuwunel application; no local passwords |
| Well-known | `/.well-known/matrix/{client,server}` served per tenant via Traefik |
| Client | Element Web or Cinny white-labeled, or a custom React client on the Matrix JS/Rust SDK |
| Calls | **Not** MatrixRTC/Element Call; calls are go-meet + LiveKit |
| Version/pinning | Pin image tags; test upgrades on a canary tenant first |

> The Matrix OIDC capability of Tuwunel was taken from the discussion and the
> project README; verify current behavior (native OIDC vs delegated auth
> service) before building the console flow — ADR-002, Q-05.

## Integration model ("Option B")

Matrix handles async chat, DMs and the **text record**; go-meet handles
meetings (scheduling, guests, lobby, recording). They connect through:

1. **Shared identity** — the same Zitadel subject on both sides.
2. **Appservice bot** — `@meetbot:<slug>.<platform-domain>`, registered per
   tenant in Tuwunel (appservice registration file with `as_token`/`hs_token`
   stored in Infisical).
3. **Room mapping** — go-meet stores `meet_room.matrix_room_id`; Matrix rooms
   created by go-meet use alias `#meet_<id>:<server>`.

### Scenarios (cards on the diagram)

**A. Call from chat.** The client calls go-meet
`POST /api/v1.0/rooms/instant { matrix_room_id }`. go-meet creates a room,
returns the link, and the bot posts a "Meeting started — Join" event into the
Matrix room. The sender joins through the normal join flow ([06](/architecture/calls-livekit)).

**B. Chat during the call.** The meeting UI embeds the Matrix client against
Tuwunel for the in-call chat panel. At meeting creation go-meet (via the
homeserver admin API / appservice) creates or reuses the meeting's Matrix room
and sets power levels from meeting access (owner/admin → moderator, members →
default). Messages persist after the call. LiveKit data channels are **not**
used for chat; `canPublishData` is granted only if another feature needs it.

**C. After the call.** go-meet's bot posts a recording-ready card (presigned
link generated on click, not at posting time), transcript and AI summary. The
Matrix room is therefore the complete text trail of a meeting.

**D. Guests.** Guests join through the go-meet link and lobby and never get a
Matrix account. Their in-call chat must be bridged: go-meet subscribes a
headless participant to the LiveKit room and mirrors data messages into the
meeting room as `guest: <name>` (adds one bridge per active call). Alternative:
guests get no chat. See Q-06.

## Data ownership

| Data | Owner | Where |
|---|---|---|
| Messages, rooms, membership, reactions | Tuwunel | RocksDB tenant volume |
| Chat attachments | Tuwunel | Tenant volume (or tenant bucket prefix `chat-media/` if offloaded) |
| Meetings, schedules, ACLs, lobby, recordings metadata | go-meet | Tenant DB on shard |
| Recordings, transcripts | go-meet via Egress | Tenant bucket |
| Identity | Zitadel | Shared instance |

## Operational notes

* Tuwunel is a single process; the tenant's Matrix is a single point of failure
  for that tenant. RocksDB backups are volume snapshots taken with the
  container quiesced (or using Tuwunel's supported backup mechanism).
* Rate limits and registration are admin-controlled (no open registration).
* Per-tenant resource caps (CPU/memory) are set on the Coolify service so one
  busy chat cannot starve others on the host.
