ConversationalAIClient
Methods
addEventListener
addEventListener(event: | , callback: Function
): void
Adds a handler for the specified ElevenLabs.ConversationalAIEvents or ElevenLabs.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., ElevenLabs.ConversationalAIEvents.UserTranscript)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
clearMediaBuffer
clearMediaBuffer(parameters: ): void
Clears the ElevenLabs WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
clientToolResult
clientToolResult(parameters: Object
): void
Result of the client tool call. https://elevenlabs.io/docs/conversational-ai/api-reference/conversational-ai/websocket#send.Client-Tool-Result
Parameters
parameters:
Object
Returns
type:
void
close
close(): void
Closes the ElevenLabs connection (over WebSocket) or connection attempt.
Returns
type:
void
contextualUpdate
contextualUpdate(parameters: Object
): void
Allows to send non-interrupting background information to the conversation. https://elevenlabs.io/docs/conversational-ai/api-reference/conversational-ai/websocket#send.Contextual-Update
Parameters
parameters:
Object
Returns
type:
void
conversationInitiationClientData
conversationInitiationClientData(parameters: Object
): void
Defines what can be customized when starting a conversation. https://elevenlabs.io/docs/conversational-ai/api-reference/conversational-ai/websocket#send.Conversation-Initiation-Client-Data
Parameters
parameters:
Object
Returns
type:
void
id
id(): string
Returns the ConversationalAIClient id.
Returns
type:
string
removeEventListener
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified ElevenLabs.ConversationalAIEvents or ElevenLabs.Events event.
Parameters
event:
Event class (i.e., ElevenLabs.ConversationalAIEvents.UserTranscript)
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 ElevenLabs (via WebSocket) to the media unit. ElevenLabs works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the ElevenLabs (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
userMessage
userMessage(parameters: Object
): void
Allows to send user text messages to the conversation.
Parameters
parameters:
Object
Returns
type:
void
webSocketId
webSocketId(): string
Returns the ElevenLabs WebSocket id.
Returns
type:
string