How the connection starts
You can create a stream in two ways:- Return a
<Stream>XML element from the call’s Answer URL. - Start an Audio Stream through REST on an active call.
start event, and then sends inbound media events while the call is active.
Treat the audio directions separately
Inbound stream formats
Vobiz reports the selected inbound format instart.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 withplayAudio.
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: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, andstart.mediaFormatfrom thestartevent. - 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.