Real-time Messaging
The platform uses WebSockets for real-time message delivery, event streaming, and live notifications. Learn how real-time communication works.
The platform provides real-time communication through WebSocket connections. Messages, events, and notifications are delivered instantly to connected clients.
WebSocket connections
Clients (browsers, mobile apps) establish a persistent WebSocket connection to the platform. Once connected, the client can:
- Subscribe to event topics (conversations, notifications, task updates)
- Receive real-time events as they happen
- Unsubscribe from topics they no longer need
Connection lifecycle
- Connect — the client opens a WebSocket connection (HTTP upgrade)
- Authenticate — the connection is associated with the user's session
- Subscribe — the client subscribes to topics of interest
- Receive events — the server pushes events matching subscribed topics
- Disconnect — on close, all subscriptions are cleaned up
Keep-alive
The platform maintains connection health through ping/pong frames:
- The server sends periodic pings
- Clients must respond with pongs within the timeout window
- Connections that fail to respond are closed and cleaned up
Topic subscriptions
Clients subscribe to topics that follow a hierarchical naming pattern:
events.{orgId}.{source}.{resource}.{event}.{resourceId}Examples:
| Topic pattern | What you receive |
|---|---|
events.org_123.conversations.conversation.message_posted.* | All new messages in org_123 |
events.org_123.conversations.conversation.message_posted.conv_456 | Messages in a specific conversation |
events.org_123.tasks.task.completed.* | All task completions in org_123 |
events.org_123.flows.flow.run.* | All flow runs in org_123 |
Wildcards (*) enable flexible subscriptions — subscribe to all events of a type, or narrow to a specific resource.
Message streaming
When an agent generates a response, the tokens are streamed in real time:
- The assistant engine starts generating the response
- As each token is produced, a
message_streamevent is published - Connected clients subscribed to the conversation topic receive each token
- The response appears progressively in the UI
This provides a responsive experience — users see the agent's response as it's being generated rather than waiting for the complete response.
Event delivery
Real-time events follow this path:
Service publishes event
→ Event bus (NATS)
→ WebSocket server
→ Match against client subscriptions
→ Deliver to subscribed clientsThe WebSocket server subscribes to the event bus and routes events to the appropriate connected clients based on their topic subscriptions.
Notifications
The notification system builds on real-time events:
- Platform events (new messages, task completions, etc.) are evaluated against notification rules
- Matching rules generate notifications with content, priority, and recipient
- Notifications are delivered through the appropriate channel:
- WebSocket — for connected clients (instant)
- Push — for mobile clients (via push notification services)
- Email — for offline delivery
See Notifications for details on configuring notification rules.
Related concepts
- Rooms and Participants — the conversation structure
- Event System — the underlying event bus
- Notifications — event-driven user notifications
Rooms and Participants
Rooms are persistent containers for conversations. Participants are the users and agents that interact within rooms, with configurable auto-respond behavior.
Event System
The platform's distributed event system enables real-time communication between services, external event ingestion, and notification delivery through a topic-based pub/sub architecture.