Cartesia provides a VoxEngine client for connecting a call or media unit to the Cartesia Agents WebSocket API.
Use Cartesia.createAgentsClient(...) to create an AgentsClient for the current scenario.
Add the module before using the namespace:
Create the client, bridge media, and listen for Cartesia Agents events.
Creates a Cartesia.AgentsClient instance.
Parameters
Returns
Creates a new Cartesia.RealtimeTTSPlayer instance with the specified text (TTS is used to play the text). You can attach media streams later via the Cartesia.RealtimeTTSPlayer.sendMediaTo or VoxEngine.sendMediaBetween methods.
Parameters
Returns
Adds a handler for the specified Cartesia.AgentsEvents or Cartesia.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.
Parameters
Returns
Clears the Cartesia WebSocket media buffer.
Parameters
Returns
Closes the Cartesia connection (over WebSocket) or connection attempt.
Parameters
This method does not accept parameters.
Returns
Sends custom metadata to the agent. https://docs.cartesia.ai/line/integrations/web-calls#custom-event
Parameters
Returns
Sends DTMF (dual-tone multi-frequency) tones. https://docs.cartesia.ai/line/integrations/web-calls#dtmf-event
Parameters
Returns
Returns the AgentsClient id.
Parameters
This method does not accept parameters.
Returns
Removes a handler for the specified Cartesia.AgentsEvents or Cartesia.Events event.
Parameters
Returns
Starts sending media from the Cartesia (via WebSocket) to the media unit. Cartesia works in real time.
Parameters
Returns
Initializes the audio stream configuration. https://docs.cartesia.ai/line/integrations/web-calls#start-event
Parameters
Returns
Stops sending media from the Cartesia (via WebSocket) to the media unit.
Parameters
Returns
Returns the Cartesia WebSocket id.
Parameters
This method does not accept parameters.
Returns
These events describe audio received through the Cartesia WebSocket media bridge.
Triggered when the audio stream sent by a third party through a Cartesia WebSocket is started playing.
Event constant: Events.WebSocketMediaStarted
Payload
Triggers after the end of the audio stream sent by a third party through a Cartesia WebSocket (1 second of silence).
Event constant: Events.WebSocketMediaEnded
Payload
These events mirror server messages from the Cartesia Agents WebSocket API. The data field contains the provider event payload.
The unknown event.
Event constant: AgentsEvents.Unknown
Payload
The HTTP response event.
Event constant: AgentsEvents.HTTPResponse
Payload
Server acknowledgment of the start event, confirming stream configuration. https://docs.cartesia.ai/line/integrations/web-calls#ack-event
Event constant: AgentsEvents.ACK
Payload
Indicates the agent wants to clear/interrupt the current audio stream. https://docs.cartesia.ai/line/integrations/web-calls#clear-event
Event constant: AgentsEvents.Clear
Payload
Server sends DTMF tones from the agent. https://docs.cartesia.ai/line/integrations/web-calls#dtmf-event-2
Event constant: AgentsEvents.DTMF
Payload
Server sends custom metadata from the agent. https://docs.cartesia.ai/line/integrations/web-calls#custom-event-2
Event constant: AgentsEvents.Custom
Payload
The WebSocket error response event.
Event constant: AgentsEvents.WebSocketError
Payload
Contains information about connector.
Event constant: AgentsEvents.ConnectorInformation
Payload