Adds a participant to a voice task.
The unique identifier (SID) of the voice task to add the participant to.
The phone number of the participant to be added.
An optional parameter for specifying additional options for the participant.
A promise that resolves to an AddVoiceParticipantResponse object, indicating the result of the participant addition operation.
AddVoiceParticipantResponse
FlexSdkError with the following error code(s):
import { createClient } from "@twilio/flex-sdk";import { AddExternalVoiceParticipant } from "@twilio/flex-sdk/actions/Voice";async function addExternalVoiceParticipant() { const client = await createClient("SDK_TOKEN"); const addParticipant = new AddExternalVoiceParticipant( "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "+1234567890" ); const { pendingParticipantResponse, waitForParticipantToSettle } = await client.execute(addParticipant); return { pendingParticipantResponse, waitForParticipantToSettle };} Copy
import { createClient } from "@twilio/flex-sdk";import { AddExternalVoiceParticipant } from "@twilio/flex-sdk/actions/Voice";async function addExternalVoiceParticipant() { const client = await createClient("SDK_TOKEN"); const addParticipant = new AddExternalVoiceParticipant( "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "+1234567890" ); const { pendingParticipantResponse, waitForParticipantToSettle } = await client.execute(addParticipant); return { pendingParticipantResponse, waitForParticipantToSettle };}
import { createClient, AddExternalVoiceParticipant, TaskParticipant,} from "@twilio/flex-sdk";import { Worker } from "@twilio/flex-sdk/taskrouter";async function addExternalVoiceParticipantWithCustomWorker() { const TOKEN = "SDK_TOKEN"; const worker = new Worker(TOKEN); const client = await createClient(TOKEN, { worker }); const addParticipant = new AddExternalVoiceParticipant( "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "+1234567890" ); const { pendingParticipantResponse, waitForParticipantToSettle } = await client.execute(addParticipant); console.log(pendingParticipantResponse); waitForParticipantToSettle .then((participant: TaskParticipant) => console.log("waitForParticipantToSettle", participant) ) .catch((err) => console.log("waitForParticipantToSettle", err)); return { pendingParticipantResponse, waitForParticipantToSettle };} Copy
import { createClient, AddExternalVoiceParticipant, TaskParticipant,} from "@twilio/flex-sdk";import { Worker } from "@twilio/flex-sdk/taskrouter";async function addExternalVoiceParticipantWithCustomWorker() { const TOKEN = "SDK_TOKEN"; const worker = new Worker(TOKEN); const client = await createClient(TOKEN, { worker }); const addParticipant = new AddExternalVoiceParticipant( "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "+1234567890" ); const { pendingParticipantResponse, waitForParticipantToSettle } = await client.execute(addParticipant); console.log(pendingParticipantResponse); waitForParticipantToSettle .then((participant: TaskParticipant) => console.log("waitForParticipantToSettle", participant) ) .catch((err) => console.log("waitForParticipantToSettle", err)); return { pendingParticipantResponse, waitForParticipantToSettle };}
Optional
Adds a participant to a voice task.
Param: taskSid
The unique identifier (SID) of the voice task to add the participant to.
Param: phoneNumber
The phone number of the participant to be added.
Param: options
An optional parameter for specifying additional options for the participant.
Returns
A promise that resolves to an
AddVoiceParticipantResponseobject, indicating the result of the participant addition operation.Throws
FlexSdkError with the following error code(s):
Example
Example: When initializing the SDK with custom Worker