Requesting streaming using Dial Command
The requesting dial command can be extended in the following way to request streaming using WebSockets:stream_url- the destination address when the stream is going to be delivered.stream_track- specifies which track should be streamed, with possible options:inbound_track(default)-
outbound_track -
both_tracks
Requesting streaming using Answer Command
Using the same attributes as above, streaming can be requested while answering the call:Streaming process flow
When the WebSocket connection is established, the following event is being sent:streaming.started webhook is sent:
stream_id that identifies a particular stream:
The order of events is not guaranteed and the chunk number can be used to reorder the events.
Currently only one streaming/fork operation is supported per call. In case of requesting media forking the WebSocket stream will be stopped and replaced by a RTP connection.
Bidirectional media streaming
Sending RTP stream
The RTP stream can be sent to the call using websocket. The functionality can be enabled by settingstream_bidirectional_mode to rtp. For dial command it should look as follows:
The number of bidirectional RTP streams per call is limited to 1.
RTP stream codec
There are the following codecs supported by bidirectional streaming:- PCMU, 8 kHz (default)
- PCMA, 8 kHz
- G722, 8 kHz
- OPUS, 8 kHz, 16 kHz
- AMR-WB, 8 kHz, 16 kHz
- L16, 16 kHz
When the audio is sent using a different encoding than on the call, it will be transcoded, which may cause a degradation in quality.
The L16 codec provides improved support for AI voice agent integrations by offering reduced latency and eliminating transcoding overhead when interfacing with many AI platforms that natively support linear PCM audio.
Sending media files
Media files can also be sent back to the call through the websocket. This is done similarly to the playback_start command when using a base64-encoded mp3 file in the payload. Send a packet to the websocket connection as follows:- Media payloads can only be submitted once per second.
- Media must be base64 encoded mp3.
Clear message
Sending a clear message will immediately stop the media playing on the stream and clear the media queue.Mark message
Mark messages can be used to keep track of media ending on the stream:- You can send a mark message to the stream after a media message.
- When the media immediately preceding the mark finishes you will receive the same mark back.
clear message will also result in all queued marks being sent back.
DTMF message
In case of DTMF events on the call, the following message will be sent over websocket:occurred_at field is a timestamp captured on the Telephony engine side. These are consumed as asynchronous events and in certain circumstances may arrive out of order. This field can be used to ensure proper order.