Skip to main content

WebSocket Messages

Incoming Messages (Teler -> Your app)

start

A start message contains metadata about the stream.

It is always the first message sent on the WebSocket before any media streaming begins.

{
"type": "start",
"account_id": uuid,
"call_app_id": uuid,
"call_id": uuid,
"stream_id": uuid,
"message_id": 1,
"data": {
"encoding": "audio/l16",
"sample_rate": 8_000,
"channels": 1
}
}

audio

An audio message contains the audio chunk encoded in Base64.

The size of the chunk is decided by the chunk_size parameter in the Stream flow

{
"type": "audio",
"stream_id": uuid,
"message_id": integer,
"data": {
"audio_b64": {BASE64_ENCODED_AUDIO_CHUNK}
}
}

Outgoing Messages (Your app -> Teler)

audio

An audio message contains the audio chunk encoded in Base64 and a corresponding unique chunk_id. This audio chunk will be queued and played on the call.

The chunk_id can later be used in an interrupt message to halt/cancel the chunk's playback.

{
"type": "audio",
"data": {
"audio_b64": {BASE64_ENCODED_AUDIO_CHUNK},
"chunk_id": 123
}
}

interrupt

An interrupt message can be used to interrupt a previously queued chunk's playback.

{
"type": "interrupt",
"chunk_id": 123
}

clear

A clear message can be used to wipe out the entire buffer of queued chunks at once.

{
"type": "clear"
}