Rate this page:

WebSocketAPIClient

Methods

addEventListener

Copy URL
addEventListener(event: 

Events

|

WebSocketAPIEvents

,
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

Returns

  • type:

    void

clearMediaBuffer

Copy URL
clearMediaBuffer(parameters: 

ClearMediaBufferParameters

):

void

Clears the Ultravox WebSocket media buffer.

Parameters

Returns

  • type:

    void

clientToolResult

Copy URL
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

Copy URL
close(): 

void

Closes the Ultravox connection (over WebSocket) or connection attempt.

Returns

  • type:

    void

id

Copy URL
id(): 

string

Returns the WebSocketAPIClient id.

Returns

  • type:

    string

inputTextMessage

Copy URL
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

Copy URL
removeEventListener(event: 

Events

|

WebSocketAPIEvents

,
callback:

Function

):

void

Removes a handler for the specified Ultravox.WebSocketAPIEvents or Ultravox.Events event.

Parameters

Returns

  • type:

    void

sendMediaTo

Copy URL
sendMediaTo(mediaUnit: 

VoxMediaUnit

,
parameters:

SendMediaParameters

):

void

Starts sending media from the Ultravox (via WebSocket) to the media unit. Ultravox works in real time.

Parameters

Returns

  • type:

    void

setOutputMedium

Copy URL
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

Copy URL
stopMediaTo(mediaUnit: 

VoxMediaUnit

):

void

Stops sending media from the Ultravox (via WebSocket) to the media unit.

Parameters

Returns

  • type:

    void

webSocketId

Copy URL
webSocketId(): 

string

Returns the Ultravox WebSocket id.

Returns

  • type:

    string