Adds a voice event listener to the client.
The event name (e.g. "incoming" or VoiceClientEvent.Incoming).
The event listener function.
Optional parameters for adding the event listener, containing an optional custom voice device.
A promise which resolves to an object containing the unsubscribe function to remove the listener.
FlexSdkError with the following error code(s):
import { createClient } from "@twilio/flex-sdk";import { AddVoiceEventListener, VoiceClientEvent } from "@twilio/flex-sdk/actions/Voice";const client = await createClient("SDK_TOKEN");const addVoiceEventListener = new AddVoiceEventListener(VoiceClientEvent.Incoming, (call) => { // Handle incoming call});const { unsubscribe } = await client.execute(addVoiceEventListener);// call unsubscribe if defined to remove the listener when neededunsubscribe(); Copy
import { createClient } from "@twilio/flex-sdk";import { AddVoiceEventListener, VoiceClientEvent } from "@twilio/flex-sdk/actions/Voice";const client = await createClient("SDK_TOKEN");const addVoiceEventListener = new AddVoiceEventListener(VoiceClientEvent.Incoming, (call) => { // Handle incoming call});const { unsubscribe } = await client.execute(addVoiceEventListener);// call unsubscribe if defined to remove the listener when neededunsubscribe();
Optional
Adds a voice event listener to the client.
Param: eventName
The event name (e.g. "incoming" or VoiceClientEvent.Incoming).
Param: listener
The event listener function.
Param: options
Optional parameters for adding the event listener, containing an optional custom voice device.
Returns
A promise which resolves to an object containing the unsubscribe function to remove the listener.
Throws
FlexSdkError with the following error code(s):
Example