WebSocketAPIClient
Methods
addEventListener
Adds a handler for the specified Ultravox.WebSocketAPIEvents or Ultravox.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.
Parameters
event:
Event class (i.e., Ultravox.WebSocketAPIEvents.Transcript)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
clearMediaBuffer
Clears the Ultravox WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
clientToolResult
Contains the result of a client tool invocation. https://docs.ultravox.ai/apps/datamessages#clienttoolresult-and-dataconnectiontoolresult
Parameters
parameters:
Object
Returns
type:
void
close
Closes the Ultravox connection (over WebSocket) or connection attempt.
Returns
type:
void
dataConnectionToolResult
Contains the result of a client tool invocation. https://docs.ultravox.ai/apps/datamessages#clienttoolresult-and-dataconnectiontoolresult
Parameters
parameters:
Object
Returns
type:
void
forcedAgentMessage
Forces the agent to say a specific message or invoke tools. https://docs.ultravox.ai/apps/datamessages#forcedagentmessage
Parameters
parameters:
Object
Returns
type:
void
hangUp
Instructs the agent to end the call with an optional farewell message. https://docs.ultravox.ai/apps/datamessages#hangup
Parameters
parameters:
Object
Returns
type:
void
id
Returns the WebSocketAPIClient id.
Returns
type:
string
inputTextMessage
Used to send a user message to the agent via text. Note: This method is deprecated, use 'userTextMessage' instead.
Parameters
parameters:
Object
Returns
type:
void
removeEventListener
Removes a handler for the specified Ultravox.WebSocketAPIEvents or Ultravox.Events event.
Parameters
event:
Event class (i.e., Ultravox.WebSocketAPIEvents.Transcript)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
sendMediaTo
Starts sending media from the Ultravox (via WebSocket) to the media unit. Ultravox works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
setOutputMedium
Sets server’s output medium to text or voice. https://docs.ultravox.ai/datamessages#setoutputmedium
Parameters
parameters:
Object
Returns
type:
void
stopMediaTo
Stops sending media from the Ultravox (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
userTextMessage
A user message sent via text. The message appears to the agent as if it came from the user. https://docs.ultravox.ai/apps/datamessages#usertextmessage
Parameters
parameters:
Object
Returns
type:
void
webSocketId
Returns the Ultravox WebSocket id.
Returns
type:
string