VoiceAgentClient
Methods
addEventListener
addEventListener(event: | , callback: Function
): void
Adds a handler for the specified Deepgram.VoiceAgentEvents or Deepgram.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., Deepgram.VoiceAgentEvents.SettingsApplied)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
clearMediaBuffer
clearMediaBuffer(parameters: ): void
Clears the VoiceAgent WebSocket media buffer.
Parameters
parameters:
OptionalOptional. Media buffer clearing parameters
Returns
type:
void
close
close(): void
Closes the VoiceAgent connection (over WebSocket) or connection attempt.
Returns
type:
void
id
id(): string
Returns the VoiceAgentClient id.
Returns
type:
string
removeEventListener
removeEventListener(event: | , callback: Function
): void
Removes a handler for the specified Deepgram.VoiceAgentEvents or Deepgram.Events event.
Parameters
event:
Event class (i.e., Deepgram.VoiceAgentEvents.SettingsApplied)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
sendFunctionCallResponse
sendFunctionCallResponse(input: Object
): void
Send a message to provide a function call response in the middle of a conversation. https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1SendFunctionCallResponse
Parameters
input:
Object
Returns
type:
void
sendInjectAgentMessage
sendInjectAgentMessage(input: Object
): void
Send a message to immediately trigger an Agent statement. https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectAgentMessage
Parameters
input:
Object
Returns
type:
void
sendInjectUserMessage
sendInjectUserMessage(input: Object
): void
Send a text based message to the agent. https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1InjectUserMessage
Parameters
input:
Object
Returns
type:
void
sendMediaTo
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the VoiceAgent (via WebSocket) to the media unit. VoiceAgent works in real time.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional interaction parameters
Returns
type:
void
sendUpdatePrompt
sendUpdatePrompt(input: Object
): void
Send a message to update the system prompt of the agent. https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdatePrompt
Parameters
input:
Object
Returns
type:
void
sendUpdateSpeak
sendUpdateSpeak(input: Object
): void
Send a message to change the Speak model in the middle of a conversation. https://developers.deepgram.com/reference/voice-agent/voice-agent#send.AgentV1UpdateSpeak
Parameters
input:
Object
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the VoiceAgent (via WebSocket) to the media unit.
Parameters
mediaUnit:
Media unit that stops receiving media
Returns
type:
void
webSocketId
webSocketId(): string
Returns the VoiceAgent WebSocket id.
Returns
type:
string