WebSocketAPIClient
Methods
addEventListener
addEventListener(event: | , callback: Function
): void
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
clearMediaBuffer(parameters: ): void
Clears the Ultravox WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
clientToolResult
clientToolResult(parameters: Object
): void
Contains the result of a client tool invocation. https://docs.ultravox.ai/datamessages#clienttoolresult
Parameters
parameters:
Object
Returns
type:
void
close
close(): void
Closes the Ultravox connection (over WebSocket) or connection attempt.
Returns
type:
void
id
id(): string
Returns the WebSocketAPIClient id.
Returns
type:
string
inputTextMessage
inputTextMessage(parameters: Object
): void
Used to send a user message to the agent via text. https://docs.ultravox.ai/datamessages#inputtextmessage
Parameters
parameters:
Object
Returns
type:
void
removeEventListener
removeEventListener(event: | , callback: Function
): void
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
sendMediaTo(mediaUnit: , parameters: ): void
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
setOutputMedium(parameters: Object
): void
Sets server’s output medium to text or voice. https://docs.ultravox.ai/datamessages#setoutputmedium
Parameters
parameters:
Object
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the Ultravox (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
webSocketId
webSocketId(): string
Returns the Ultravox WebSocket id.
Returns
type:
string