The Chat Voice API provides methods to create and manage voice sessions through WebSocket communication. This document describes the available endpoints and the structure of the messages that can be sent and received through these endpoints.
Replace {host} with the appropriate hostname to connect to the WebSocket server.
The apiKey parameter is required and should be added from the console (check your documentation for the corresponding parameters). For more info, see API Authentication
Message types
The Chat Voice API uses JSON-based message exchange. The messages are grouped into the following categories:
Incoming
The incoming messages are used to acknowledge a connection event sent by Talkdesk.
ConnectedMessage
This message starts a connection session with Talkdesk and marks the event as connected.
The number used to keep track of the message-sending order. The first message starts with 1 and is incremented for each message.
streamSid
String
Yes
A unique identifier of the Twilio stream.
media
Object
Yes
An object containing media metadata and payload. Additional properties are allowed.
payload
String
No
Raw audio encoded in base64.
chunk
String
No
The chunk for the message. The first message starts with 1 and is incremented for each message.
track
String
No
One of inbound or outbound.
timestamp
String
No
Presentation Timestamp in Milliseconds from the start of the stream
event
String
No
Indicates the event type. It must be set to media.
MarkCallbackMessage
This message is sent to connector to notify that the audio ends or there is no buffered audio. It is sent in case if the MarkCallbackMessage was sent after the MediaMessage.
The number used to keep track of the message-sending order. The first message starts with 1 and is incremented for each message.
streamSid
String
Yes
A unique identifier of the Twilio stream.
event
String
No
Indicates the event type. It must be set to mark.
mark
Object
Yes
An object containing the mark metadata. Additional properties are allowed.
name
String
No
The value specified when creating the mark message.
StartMessage
This message contains important metadata about the conversation and is sent immediately after the ConnectedMessage. It is only sent to connector once, at the start of the conversation.
Contains additional properties related to the stop command.
ringGroup
String
No
Describes a specific ring group, if applicable.
command
String
No
Specifies a command related to stopping the stream.
event
String
No
Indicates the event type. It must be set to stop.
MarkMessage
This message is used to notify that the audio streamed by the connector has been completed. This message should be sent after the MediaMessage. The connector will receive a MarkCallbackMessage event with the matching name from Talkdesk when the audio ends or if there is no buffered audio. If the ClearMessage is used, the connector will also receive a MarkCallbackMessage event when the buffer clears.
Indicates the event type. It must be set to mark. Additional properties are allowed.
mark
Object
No
Contains additional properties related to the mark event.
name
String
No
A name that identifies this specific mark event.
ClearMessage
This message is used to interrupt the audio stream. It will cancel all MediaMessages that are buffered and have not yet been played. This action will empty all buffered audio data and trigger a MarkCallbackMessage event to be sent back to the connector.
Click to see the details
Payload example
JSON
{
"streamSid": "string",
"event": "clear"
}
Parameter
Type
Required
Description
streamSid
String
No
A unique identifier of the Twilio stream.
event
String
Indicates the event type. It must be set to clear.
MediaMessage
This message sends an audio stream from the connector to Talkdesk. The media messages will be buffered and played in the order received. To interrupt the buffered audio, ClearMessage needs to be sent.