Creating a WebSocket Call
Creating a WebSocket-based call with Ultravox requires settingmedium to serverWebSocket and passing in parameters for sample rates and buffer size.
- inputSampleRate (required): Sample rate for input (user) audio (e.g., 48000).
- outputSampleRate (optional): Sample rate for output (agent) audio (defaults to inputSampleRate).
- clientBufferSizeMs (optional): Size of the client-side audio buffer in milliseconds. Smaller buffers allow for faster interruptions but may cause audio underflow if network latency fluctuates too greatly. For the best of both worlds, set this to some large value (e.g. 30000) and implement support for PlaybackClearBuffer messages. (Defaults to 60).
Example: Creating an Ultravox Call for WebSockets
Example: Joining an Ultravox Call via Websockets
Data Messages
WebSocket connections use the same message format as WebRTC data channels. See our Data Messages documentation for detailed message specifications.
WebSocket connections use the same message format as WebRTC data channels. See our Data Messages documentation for detailed message specifications.