Skip to main content
Vobiz can fork live call audio to your WebSocket application. Your application can transcribe the caller, run agent logic, generate speech, and send audio back to the caller on the same connection. Use WebSocket streaming when you want to own the STT, agent, TTS, voice-activity detection, barge-in, and conversation state.

How the connection starts

You can create a stream in two ways: For a bidirectional XML stream:
Vobiz connects to your WebSocket, sends a start event, and then sends inbound media events while the call is active.

Treat the audio directions separately

The two directions can use different supported formats. Always identify a format by its direction instead of using the ambiguous phrase “stream sample rate.”
To play 24 kHz agent audio, send genuine L16/24 kHz data in playAudio with sampleRate: 24000. Do not configure inbound <Stream contentType> or REST content_type as L16/24 kHz for this purpose.

Inbound stream formats

Vobiz reports the selected inbound format in start.mediaFormat. Use start.mediaFormat to configure your Base64 decoder, audio processor, or STT service for every connection.

Outbound playback formats

Your application sends agent or TTS audio with playAudio.
The payload must be raw mono audio without a WAV, MP3, or other container header. Its real encoding and sample rate must match the metadata in the event.
A 24 kHz outbound payload does not guarantee 24 kHz audio at the handset. The phone-facing carrier, SIP, or PSTN leg may use a lower-rate codec.

WebSocket protocol

Vobiz sends: Your application sends: When the call ends, Vobiz closes the WebSocket. Treat the close event as the in-band end-of-stream signal instead of waiting for an inbound stop JSON event.

Voice-agent flow

Chunking and barge-in

Send outbound playback in approximately 20–60 ms chunks. This range is recommended for responsive barge-in; it is not a protocol requirement. For 20 ms of mono audio: When your voice-activity detector confirms that the caller is interrupting, send clearAudio with the active streamId. Audio removed before its checkpoint may not produce a playedStream event, so add a timeout to checkpoint-dependent application logic.

Format conversion

Convert audio only when the next system requires another format:
Do not automatically downsample every TTS response to μ-law/8 kHz. If your application sends supported L16 playback, declare the actual L16 rate in playAudio. If your integration is configured for μ-law/8 kHz, resample and encode the payload before sending it.

Implementation responsibilities

Your application must:
  • Keep per-call state for each WebSocket connection.
  • Save callId, streamId, and start.mediaFormat from the start event.
  • Validate outbound audio before sending it.
  • Serialize concurrent WebSocket writes.
  • Clear queued playback when the caller interrupts.
  • Handle conditional checkpoint acknowledgments and timeouts.
  • Clean up STT, TTS, buffers, and conversation state on WebSocket close.

Next steps