Connection flow
Endpoint
bot_id identifies which bot configuration to fetch from CXB API.
Audio format
| Property | Value |
|---|---|
| Encoding | LINEAR16 (signed 16-bit PCM) |
| Sample rate | 8,000 Hz |
| Channels | Mono |
| Transport encoding | Base64 in JSON payload field |
Handshake events
The dialler sends exactly three events after connection:connected
connected
First event. Contains caller metadata.
All fields from the
| Field | Type | Description |
|---|---|---|
event | string | "connected" |
callerId | string | Caller’s phone number |
did | string | Dialled number (DID) |
callDirection | string | "incoming" or "outgoing" |
streamId | string | Stream identifier (optional, may come in start) |
connected event (minus event) are forwarded to CXB API as connected_event query params during config fetch.start
start
Second event. Contains stream and media format info.
| Field | Type | Description |
|---|---|---|
event | string | "start" |
streamId | string | Stream identifier |
mediaFormat | object | Audio format metadata |
answer
answer
Third event. Signals handshake complete, pipeline can start.
| Field | Type | Description |
|---|---|---|
event | string | "answer" |
Protocol events
Incoming (dialler → CXB Core)
| Event | Description |
|---|---|
media | Audio frame. payload field contains base64-encoded LINEAR16 PCM. |
hangup-call | Customer or network disconnection. disconnectedBy field indicates source. |
Outgoing (CXB Core → dialler)
| Event | Description |
|---|---|
reverse-media | Bot audio response. Base64-encoded LINEAR16 PCM in payload. |
reverse-media-stop | Clears the dialler’s audio buffer. Sent before hangup. |
reverse-hangup-call | Drops the call. Sent after reverse-media-stop. |
reverse-call-transfer | Transfers the call to a specified number. |
reverse-media payload
Hangup behavior
Bot-initiated hangup:- CXB Core sends
reverse-media-stop(clears audio buffer) - CXB Core sends
reverse-hangup-call disconnected_by="bot"
- Dialler sends
hangup-callevent - CXB Core receives
CancelFrame, pipeline winds down disconnected_by="customer"
Transfer behavior
When the bot transfers the call, CXB Core sends a singlereverse-call-transfer event (transfer method websocket_reverse_transfer) carrying the destination transferno. Transfer is terminal for the bot leg: CXB Core sets the serializer’s _hangup_sent flag so the EndFrame auto-hangup does not fire a reverse-hangup-call after the transfer.
Outside active hours
If CXB API returns no config (bot unavailable or outside its active-hours window),fetch_config() returns None. CXB Core drops the call immediately by sending reverse-media-stop followed by reverse-hangup-call to the dialler, and records disconnected_by = "outside_hours".
Capacity
When a worker is atMAX_CONCURRENT_CALLS, new WebSocket connections are rejected with close code 1008 (“Server at capacity”). The nginx least_conn balancer routes to the least-loaded worker.