Realtime Chat Inbox Architecture
The Realtime Chat Inbox enables multi-agent customer support over WhatsApp with low-latency WebSocket message broadcasting.
Architecture Blueprint
Rendering diagram...
WebSocket Specification
- Endpoint:
/ws/inbox/<tenant_id>/ - Protocol: (WebSocket Secure)
WSS - Channel Group:
inbox_<tenant_id>
Event Payload Frames
1. Inbound Customer Message Event
json
{
"type": "new_message",
"data": {
"id": "c7a812e9-45bc-48d2-81e1-92fa023bf891",
"conversation_id": "96598ec0-9ee5-4e10-9948-85894cbc9fcf",
"sender_phone": "+14155552671",
"content": "Hello! I need help with my order.",
"direction": "inbound",
"timestamp": "2026-07-24T01:20:00Z"
}
}
2. Message Status Update Event
json
{
"type": "message_status_update",
"data": {
"message_id": "c7a812e9-45bc-48d2-81e1-92fa023bf891",
"status": "read",
"updated_at": "2026-07-24T01:20:05Z"
}
}
Fault Tolerance & Reconnection
- Heartbeat Ping/Pong: Ping frames sent every 30 seconds to maintain connection health.
- Automatic Reconnection: hook in Next.js implements exponential backoff reconnection on disconnection.
useWebSocket