///
import { Call } from '@twilio/voice-sdk';
import { ConferenceOptions } from 'twilio-taskrouter';
import { Device } from '@twilio/voice-sdk';
import { ReservationEvents } from 'twilio-taskrouter';
import { Supervisor as Supervisor_2 } from 'twilio-taskrouter';
import { Task } from 'twilio-taskrouter';
import { TransferOptions } from 'twilio-taskrouter';
import type TypedEmitter from 'typed-emitter';
import { WorkerOptions as WorkerOptions_2 } from 'twilio-taskrouter';
import { Workspace } from 'twilio-taskrouter';
/**
* Generic interface for executable actions in the Flex SDK.
* Actions represent operations that can be performed on Flex resources
* such as tasks, reservations, or participants.
*
* @example
* ```ts
* import type { Action, TaskReservation } from "@twilio/flex-sdk";
* import { createClient, AcceptTask } from "@twilio/flex-sdk";
*
* async function runAction() {
* const client = await createClient("SDK_TOKEN");
* const action: Action> = new AcceptTask("TASK_SID");
* await client.execute(action);
* }
* ```
*
* @public
*/
export declare interface Action {
run(ctx: {}): T;
}
/**
* Adds a participant to a voice task.
* @category Actions
*
* @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 `AddVoiceParticipantResponse` object, indicating the result of the participant addition operation.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.CallerIdUndefined}
* - {@link ErrorCode.FailedToAddExternalVoiceParticipant}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.MissingRequiredParameter}
*
* @example
* ```ts
* 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 };
* }
* ```
* @example When initializing the SDK with custom Worker
* ```ts
* 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 };
* }
* ```
*
* @public
*/
export declare class AddExternalVoiceParticipant implements Action> {
constructor(taskSid: string, phoneNumber: string, options?: AddExternalVoiceParticipantOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface AddExternalVoiceParticipantOptions extends AddVoiceParticipantOptions {
callerId?: string;
}
/**
* Adds a voice event listener to the client.
* @category Actions
*
* @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 {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.VoiceDeviceNotInitialized}
* - {@link ErrorCode.UnknownVoiceEventName}
* - {@link ErrorCode.FailedToAddVoiceEventListener}
*
* @example
* ```ts
* 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 needed
* unsubscribe();
* ```
*
* @public
*/
export declare class AddVoiceEventListener implements Action> {
constructor(eventName: T, listener: AddVoiceListenerEvent[T], options?: AddVoiceEventListenerOptions);
run(ctx: {}): Promise<{
unsubscribe: () => void;
}>;
}
/**
* @public
*/
export declare interface AddVoiceEventListenerOptions {
voiceDevice?: Device;
}
/**
* @public
*/
export declare interface AddVoiceEventListenerResponse {
/**
* Unsubscribe function to remove the event listener.
*/
unsubscribe: () => void;
}
/**
* @public
*/
export declare interface AddVoiceListenerEvent {
incoming: (call: VoiceCall) => void;
error: (error: Error, call?: VoiceCall) => void;
destroyed: () => void;
tokenWillExpire: () => void;
unregistered: () => void;
}
/**
* Media properties for add voice participant
* @public
*/
export declare type AddVoiceParticipantMediaProperties = {
call?: ParticipantCallProperties;
callSid?: string;
muted?: boolean;
beep?: string;
startConferenceOnEnter?: boolean;
endConferenceOnExit?: boolean;
coaching?: boolean;
hold?: boolean;
callSidToCoach?: string;
earlyMedia?: boolean;
waitUrl?: string;
waitMethod?: 'GET' | 'POST';
transcribe?: boolean;
transcriptionConfiguration?: string;
jitterBufferSize?: string;
};
/**
* Add voice participant options
* @public
*/
export declare type AddVoiceParticipantOptions = {
/**
* Type of the voice participant, 'agent', 'customer', 'supervisor' or 'external'
*/
type: ParticipantType;
/**
* The phone number the call is made from
*/
from: string;
/**
* The phone number to call to
*/
to: string;
/**
* Routing properties for the Agent participant
*/
routingProperties?: RoutingProperties;
/**
* Media properties for the Agent participant
*/
mediaProperties?: AddVoiceParticipantMediaProperties;
};
/**
* Response returned when adding a voice participant to a task.
* @public
*/
export declare interface AddVoiceParticipantResponse {
/**
* Response for the adding participant request.
*/
pendingParticipantResponse: {
/**
* The identifier of the participant who is added to the channel
*/
sid: string;
/**
* The channel sid of the channel where the participant is added
*/
channelSid: string;
/**
* The identifier of the interaction where the participant is added
*/
interactionSid: string;
/**
* Optional media properties of the participant
*/
mediaProperties: MediaProperties | null;
};
/**
* Wait for the success or failure event for adding a Participant.
*/
waitForParticipantToSettle: Promise;
}
/**
* Switches a supervisor (already joined via {@link MonitorCall}) into barge mode on the
* task's conference. The supervisor becomes audible to both the agent and the customer.
*
* @category Actions
*
* @param taskSid - The task SID for the call to barge into
*
* @returns A promise that resolves when the barge call operation is complete
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.SupervisorNotOnCall}
* - {@link ErrorCode.FailedToBargeCall}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { BargeCall } from "@twilio/flex-sdk/actions/Voice";
*
* async function example() {
* const client = await createClient("SDK_TOKEN");
* const bargeCall = new BargeCall("WTXXXXXXXXXXXXXXXXXXXXXXXXX");
* const call = await client.execute(bargeCall);
* }
* ```
*
* @public
*/
export declare class BargeCall implements Action> {
/**
* Creates a new BargeCall action.
* @param taskSid - The task SID for the call to barge into
*/
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* Properties which both {@link VoiceTaskParticipant} and {@link ConversationTaskParticipant} types have in common.
* @public
*/
export declare interface BaseParticipant {
/**
* The sid of the participant (UTxxx)
*/
readonly participantSid: string;
/**
* The type of the participant
*/
readonly type: ParticipantType;
/**
* The sid of the channel (UOxxx)
*/
readonly channelSid: string;
/**
* The sid of the interaction (KDxxx)
*/
readonly interactionSid: string;
/**
* The routing properties of the participant
*/
readonly routingProperties?: RoutingProperties | null;
readonly errorData: {
errorMessage: string;
errorCode: number;
} | null;
}
/**
* Cancels a voice task transfer.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be transferred.
*
* @returns A promise that resolves to a `Task` object, representing the canceled task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.NoActiveTransferForVoiceTask}
* - {@link ErrorCode.FailedToCancelVoiceTaskTransfer}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.TaskNotVoiceTask}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { CancelVoiceTaskTransfer } from "@twilio/flex-sdk/actions/Voice";
*
* async function cancelVoiceTaskTransfer() {
* const client = await createClient("SDK_TOKEN");
* const cancelVoiceTaskTransfer = new CancelVoiceTaskTransfer("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const canceledTask = await client.execute(cancelVoiceTaskTransfer);
* return canceledTask;
* }
* ```
*
* @public
*/
export declare class CancelVoiceTaskTransfer implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* Main interface for interacting with the Flex SDK.
* @public
*/
export declare interface Client extends TypedEmitter {
readonly roles: Array;
readonly token: string;
/**
* The current aggregate connection state of the SDK.
* Reflects network health and the state of all initialized SDKs (Conversations, Voice, TaskRouter).
* SDK fields are `undefined` when that SDK has not yet been initialized.
*
* @example
* ```ts
* const { overall, network, conversations, voice, taskrouter } = client.connectionState;
* ```
*/
readonly connectionState: SdkConnectionState;
/**
* @returns Worker object representing the current user. If the worker is already initialized, it will return immediately.
*/
getWorker: () => Promise;
/**
* @returns Workspace object. If the workspace is already initialized, it will return immediately.
*/
getWorkspace: () => Promise;
execute(action: Action): T;
/**
* Destroy the client, removing all event listeners
* @returns {Promise}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
*
* await client.destroy();
* ```
*/
destroy(): void;
/**
* This method updates the token for the session and propagates it to all connected services.
* After a successful update, the `tokenUpdated` event is emitted with both the new token and refresh token.
*
* Use this method when you need to manually refresh the token, such as when your
* application receives a new token from your backend token server.
*
* @param token - The new authentication token
* @param refreshToken - The new refresh token (optional)
*
* @example
* Listen to token update events:
* ```ts
* import { createClient, ClientEvent } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
*
* // Listen for token updates
* client.on(ClientEvent.TokenUpdated, (token, refreshToken) => {
* console.log("Token updated successfully");
* // Optionally store the new token
* });
*
* // Update the token
* client.updateToken("NEW_TOKEN", "NEW_REFRESH_TOKEN");
* ```
*/
updateToken(token: string, refreshToken?: string): void;
}
/**
* Enumeration of event names that the Flex SDK client can emit.
* @public
*/
export declare enum ClientEvent {
TokenUpdated = "tokenUpdated",
TokenAutoUpdateFailed = "tokenAutoUpdateFailed",
TokenMaxLifetimeReached = "tokenMaxLifetimeReached",
ClientDestroyed = "clientDestroyed",
ConnectionStateChanged = "connectionStateChanged"
}
/**
* Events that the Flex SDK client can emit.
* @public
*/
export declare interface ClientEventsType {
tokenUpdated: (token: string, refreshToken?: string) => void;
tokenAutoUpdateFailed: () => void;
tokenMaxLifetimeReached: (newTokenDateExpired: Date) => void;
clientDestroyed: () => void;
connectionStateChanged: (state: SdkConnectionState) => void;
[key: string]: (...args: any[]) => void;
}
/**
* Switches a supervisor (already joined via {@link MonitorCall}) into coach (whisper) mode
* for the specified agent on the task's conference. The supervisor becomes audible to that
* agent only — the customer does not hear the supervisor.
*
* @category Actions
*
* @param taskSid - The SID of the task
* @param options - Optional configuration for the coach call
*
* @returns A promise that resolves when the coach call is established
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.SupervisorNotOnCall}
* - {@link ErrorCode.FailedToCoachCall}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { CoachCall } from "@twilio/flex-sdk/actions/Voice";
*
* async function example() {
* const client = await createClient("SDK_TOKEN");
* const coachCall = new CoachCall("WTXXXXXXXXXXXXXXXXXXXXXXXXX", { targetWorkerSid: "WRXXXXXXXXXXXXXXXXXXXXXXXXX" });
* const call = await client.execute(coachCall);
* }
* ```
*
* @public
*/
export declare class CoachCall implements Action> {
/**
* Creates an instance of CoachCall.
* @param taskSid - The SID of the task
* @param options - Optional configuration for the coach call
*/
constructor(taskSid: string, options?: CoachCallOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface CoachCallOptions {
/**
* Worker SID of the agent to coach. Required when more than one agent is on the call.
* If omitted, the only agent on the call is selected.
*/
targetWorkerSid?: string;
}
/**
* The state of a single SDK or the network connection.
* @public
*/
export declare type ConnectionState = "connected" | "connecting" | "disconnected" | "notInitialized";
/**
* Media properties for conversation participants.
* @public
*/
export declare type ConversationMediaProperties = {
conversationSid: string;
friendlyName: string | null;
dateUpdated: string;
roleSid: string;
chatbotConfiguration: {
friendlyName: string | null;
chatbotProvider: string | null;
configuration: {
dialogflowcxModuleSid: string | null;
dialogflowcxAddonSid: string | null;
};
} | null;
dateCreated: string;
chatServiceSid: string;
url: string;
sid: string;
lastReadMessageIndex: number | null;
identity: string | null;
lastReadTimestamp: string | null;
messagingBinding: {
address: string;
level: ParticipantLevel | null;
proxyAddress: string | null;
name: string | null;
type: string;
projectedAddress: string | null;
} | null;
accountSid: string;
attributes: string;
} & MediaProperties;
/**
* Extends {@link BaseParticipant} with properties specific to conversation participants.
* @public
*/
export declare type ConversationTaskParticipant = BaseParticipant & {
/**
* The type of the channel
*/
readonly channelType: Exclude;
/**
* Media properties of the participant
*/
readonly mediaProperties?: ConversationMediaProperties | null;
};
/**
* Ends a call for all participants.
*
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be ended.
*
* @returns A promise that resolves to a `Task` object, representing the ended task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToEndConference}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { EndVoiceCallForAll } from "@twilio/flex-sdk/actions/Voice";
*
* async function endVoiceCallForAll() {
* const client = await createClient("SDK_TOKEN");
* const endVoiceCallForAll = new EndVoiceCallForAll("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const endedTask = await client.execute(endVoiceCallForAll);
* return endedTask;
* }
* ```
*
* @public
*/
export declare class EndVoiceCallForAll implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* Enumeration of error codes that can be thrown by the Flex SDK.
* @public
*/
export declare enum ErrorCode {
/**
* PermissionDenied error
*/
PermissionDeniedError = 20003,
/**
* Invalid access token
*/
InvalidAccessToken = 20101,
/**
* Access Token expired or expiration date invalid
*/
AccessTokenExpired = 20104,
/**
* Twilsock rate limit exceeded
*/
TooManyRequests = 20429,
/**
* Internal Server Error
*/
InternalServerError = 20500,
/**
* Service Unavailable
*/
ServiceUnavailable = 20503,
/**
* Authorization error, public error code in Flex product
*/
AuthorizationError = 45003,
/**
* Validation error, public error code in Flex product
*/
ValidationError = 45004,
/**
* Failed to remove participant during task completion
*/
FailedToRemoveParticipant = 48100,
/**
* Failed to complete reservation during task completion
*/
FailedToCompleteReservation = 48101,
/**
* Failed to end task due to internal error
*/
FailedToEndTask = 48102,
/**
* Failed to reject reservation due to internal error
*/
FailedToRejectReservation = 48103,
/**
* Failed to wrap-up reservation due to internal error
*/
FailedToWrapUpReservation = 48104,
/**
* Failed to set task attributes
*/
FailedToSetTaskAttributes = 48105,
/**
* Failed to set activity due to pending reservations
*/
FailedToSetCurrentWorkerActivityDueToPendingReservations = 48200,
/**
* Failed to set activity
*/
FailedToSetCurrentWorkerActivity = 48201,
/**
* Failed to set current worker attributes
*/
FailedToSetCurrentWorkerAttributes = 48202,
/**
* Failed to set worker activity by the supervisor
*/
FailedToSetWorkerActivityBySupervisor = 48300,
/**
* Activity change rejected due to pending tasks
*/
ActivityChangeRejectedPendingReservations = 48301,
/**
* Attributes not valid JSON
*/
FailedToSetWorkerAttributesBySupervisor = 48302,
/**
* Caller ID undefined
*/
CallerIdUndefined = 48400,
/**
* Failed to add external voice participant due to internal error
*/
FailedToAddExternalVoiceParticipant = 48401,
/**
* Failed to end conference due to internal error
*/
FailedToEndConference = 48402,
/**
* Failed to hold external participant due to internal error
*/
FailedToHoldExternalParticipant = 48403,
/**
* Failed to hold worker participant due to internal error
*/
FailedToHoldWorkerParticipant = 48404,
/**
* Failed to hold participant due to internal error
*/
FailedToHoldVoiceParticipant = 48405,
/**
* Worker cannot kick themselves from task
*/
FailedSelfKick = 48406,
/**
* Failed to kick participant due to internal error
*/
FailedToKickVoiceParticipant = 48407,
/**
* Failed to unhold external participant due to internal error
*/
FailedToUnholdExternalParticipant = 48408,
/**
* Failed to unhold worker participant due to internal error
*/
FailedToUnholdWorkerParticipant = 48409,
/**
* Failed to unhold participant due to internal error
*/
FailedToUnholdVoiceParticipant = 48410,
/**
* Worker cannot unhold reservation - reservation must be a live call assigned to the worker
*/
WorkerCannotUnholdReservation = 48411,
/**
* Worker cannot hold reservation - reservation must be a live call assigned to the worker
*/
WorkerCannotHoldReservation = 48412,
/**
* Invalid participantSid provided
*/
InvalidParticipantSid = 48413,
/**
* Voice device not initialized
*/
VoiceDeviceNotInitialized = 48414,
/**
* Unknown voice event name
*/
UnknownVoiceEventName = 48415,
/**
* Failed to add voice event listener due to internal error
*/
FailedToAddVoiceEventListener = 48416,
/**
* Failed to get call by task - call might be active on different device
*/
FailedToGetCallByTask = 48417,
/**
* Failed to get conference data from task
*/
FailedToGetConferenceData = 48418,
/**
* Supervisor is already monitoring the call for this task
*/
SupervisorAlreadyMonitoringCall = 48419,
/**
* Failed to monitor call due to internal error
*/
FailedToMonitorCall = 48420,
/**
* Parameter 'fromNumber' is required for outbound call. Provide it as a parameter or configure it in account configuration
*/
FromNumberRequired = 48421,
/**
* Task Queue SID is required for outbound call. Provide it as a parameter or configure it in account configuration
*/
TaskQueueSidRequired = 48422,
/**
* Workflow SID is required for outbound call. Provide it as a parameter or configure it in account configuration
*/
WorkflowSidRequired = 48423,
/**
* Worker is offline, outbound call cancelled
*/
WorkerOfflineOutboundCallCancelled = 48424,
/**
* Outbound calling is disabled in Flex account configuration
*/
OutboundCallingDisabled = 48425,
/**
* Inbound call is pending, outbound call cancelled
*/
InboundCallPendingOutboundCancelled = 48426,
/**
* Inbound call is accepted, outbound call cancelled
*/
InboundCallAcceptedOutboundCancelled = 48427,
/**
* No audio input device available, outbound call cancelled
*/
NoAudioInputDeviceAvailable = 48428,
/**
* No incoming call event received within 30 seconds
*/
IncomingCallTimeout = 48429,
/**
* Failed to create task due to internal error
*/
FailedToCreateTask = 48430,
/**
* Failed to disconnect call due to internal error
*/
FailedToDisconnectCall = 48431,
/**
* Voice reservation not a live call
*/
VoiceReservationNotLiveCall = 48432,
/**
* No conference SID found in task attributes
*/
NoConferenceSidFoundInTaskAttributes = 48433,
/**
* No active recording to pause
*/
NoActiveRecordingToPause = 48434,
/**
* Failed to pause recording
*/
FailedToPauseRecording = 48435,
/**
* No active recording to resume
*/
NoActiveRecordingToResume = 48436,
/**
* Failed to resume recording
*/
FailedToResumeRecording = 48437,
/**
* Call instance is undefined. Call might be active on a different device
*/
CallInstanceUndefined = 48438,
/**
* Failed to hold call
*/
FailedToHoldCall = 48439,
/**
* Failed to unhold call
*/
FailedToUnholdCall = 48440,
/**
* No active transfer found for voice task
*/
NoActiveTransferForVoiceTask = 48441,
/**
* Failed to cancel voice task transfer due to internal error
*/
FailedToCancelVoiceTaskTransfer = 48442,
/**
* Voice task transfer already initiated
*/
VoiceTaskTransferAlreadyInitiated = 48443,
/**
* Worker cannot transfer voice task assigned to different worker
*/
WorkerCannotTransferVoiceTaskFromDifferentWorker = 48444,
/**
* Failed to start voice task transfer due to internal error
*/
FailedToStartVoiceTaskTransfer = 48445,
/**
* Failed to create voice task reservation
*/
FailedToCreateVoiceTaskReservation = 48446,
/**
* Voice reservation not found
*/
VoiceReservationNotFound = 48447,
/**
* Failed to coach call due to internal error
*/
FailedToCoachCall = 48448,
/**
* Failed to barge call due to internal error
*/
FailedToBargeCall = 48449,
/**
* Supervisor is not currently on the call (call MonitorCall first)
*/
SupervisorNotOnCall = 48450,
/**
* Failed to peek conversation due to internal error
*/
FailedToPeekConversation = 48500,
/**
* Failed to pause conversation due to internal error
*/
FailedToPauseConversation = 48501,
/**
* Failed to resume conversation due to internal error
*/
FailedToResumeConversation = 48502,
/**
* Failed to leave conversation due to internal error
*/
FailedToLeaveConversation = 48503,
/**
* Failed to start conversation transfer due to internal error
*/
FailedToStartConversationTransfer = 48504,
/**
* Conversation transfers is forbidden
*/
ConversationTransferForbidden = 48505,
/**
* Conversation transfers retrieving is forbidden
*/
ConversationTransferRetrievingForbidden = 48506,
/**
* Failed to retrieve conversation transfer due to internal error
*/
FailedToRetrieveConversationTransfer = 48507,
/**
* Failed to retrieve conversations user by identity
*/
FailedToRetrieveConversationsUser = 48508,
/**
* Failed to send message due to internal error
*/
FailedToSendMessage = 48509,
/**
* Failed to send typing indicator due to internal error
*/
FailedToSendTypingIndicator = 48510,
/**
* Failed to retrieve messages due to internal error
*/
FailedToRetrieveMessages = 48511,
/**
* Worker is offline, outbound email task cancelled
*/
WorkerOfflineEmailTaskCancelled = 48512,
/**
* Failed to create outbound email task due to internal error
*/
FailedToCreateOutboundEmailTask = 48513,
/**
* Failed to add email participant due to internal error
*/
FailedToAddEmailParticipant = 48514,
/**
* Task is not an email task
*/
TaskNotEmailTask = 48515,
/**
* Failed to remove email participant due to internal error
*/
FailedToRemoveEmailParticipant = 48516,
/**
* Failed to retrieve paused conversations due to internal error
*/
FailedToRetrievePausedConversations = 48517,
/**
* No conversationSid found for task
*/
NoConversationSidFoundForTask = 48518,
/**
* Failed to get reservation after resuming the conversation
*/
FailedToGetReservationAfterConversationResuming = 48519,
/**
* Worker participant not found for provided task
*/
WorkerParticipantNotFoundForTask = 48520,
/**
* Cannot send empty message
*/
MessageContentMissing = 48521,
/**
* Failed to retrieve outbound email settings due to internal error
*/
FailedToRetrieveOutboundEmailSettings = 48522,
/**
* Outbound email workflow SID is not configured in Twilio Console nor provided in options
*/
OutboundEmailWorkflowSidUndefined = 48523,
/**
* Outbound email queue SID is not configured in Twilio Console nor provided in options
*/
OutboundEmailQueueSidUndefined = 48524,
/**
* Outbound email workflow SID is not configured in Twilio Console nor provided in options
*/
OutboundEmailFromParameterUndefined = 48525,
/**
* Failed to create conversation task reservation
*/
FailedToCreateOutboundEmailTaskReservation = 48526,
/**
* Failed to add conversation event listener due to internal error
*/
FailedToAddConversationEventListener = 48527,
/**
* Conversations SDK connection changed to invalid state
*/
ConversationsSdkConnectionInvalidState = 48528,
/**
* Failed to retrieve content templates
*/
FailedToRetrieveContentTemplates = 48529,
/**
* Failed to get channel for task due to internal error
*/
FailedToGetChannelsForTask = 48530,
/**
* Worker is not initialized
*/
WorkerNotInitialized = 48900,
/**
* Task reservation not found or has invalid status
*/
TaskReservationNotFound = 48901,
/**
* Required parameter missing
*/
MissingRequiredParameter = 48902,
/**
* Conversation is not available
*/
ConversationNotAvailable = 48903,
/**
* Participant not found
*/
ParticipantNotFound = 48904,
/**
* Failed to update token on session
*/
FailedToUpdateTokenOnSession = 48905,
/**
* Failed to initialize Conversations SDK
*/
FailedToInitializeConversationsSDK = 48906,
/**
* Missing interactionSid for task
*/
MissingTaskInteractionSid = 48907,
/**
* Missing channelSid for task
*/
MissingChannelSid = 48908,
/**
* Invalid response from public configuration endpoint
*/
InvalidResponseFromPublicConfig = 48909,
/**
* Failed to accept reservation
*/
FailedToAcceptReservation = 48910,
/**
* Failed to retrieve conversation due to internal error
*/
FailedToRetrieveConversation = 48911,
/**
* Failed to get Flex instance SID from account configuration
*/
FailedToGetFlexInstanceSid = 48912,
/**
* Failed to retrieve task participants due to internal error
*/
FailedToRetrieveTaskParticipants = 48913,
/**
* Active channel not found for task
*/
ActiveChannelNotFound = 48914,
/**
* Task is not a voice task
*/
TaskNotVoiceTask = 48915,
/**
* Taskrouter offline activity SID is not configured
*/
TaskrouterOfflineActivitySidNotConfigured = 48916,
/**
* Failed to create a conference
*/
FailedToCreateConference = 48917,
/**
* The error we did not foreseen
*/
UnexpectedError = 48918,
/**
* The error which error code we could not identify
*/
UnknownError = 48919,
/**
* Access denied
*/
AccessDeniedError = 48920,
/**
* Bad Gateway
*/
BadGateway = 48921,
/**
* Gateway Timeout
*/
GatewayTimeout = 48922,
/**
* Resource was not found
*/
NotFound = 48923,
/**
* Not able to reach the server
*/
NetworkError = 48924,
/**
* Function called in invalid state of the object
*/
InvalidState = 48925,
/**
* Invalid parameter value received as argument
*/
InvalidParams = 48926,
/**
* DownstreamServiceError error
*/
DownstreamServiceError = 48927,
/**
* Failed to fetch account configuration
*/
FailedToFetchAccountConfiguration = 48928,
/**
* Failed to fetch features
*/
FailedToFetchFeatures = 48929,
/**
* Failed to fetch features
*/
FailedToFetchPublicConfiguration = 48930,
/**
* Bad request error
*/
BadRequest = 70002,
/**
* Invalid certificate
*/
BadSsoSettings = 70251
}
/**
* Enumeration of different error severity levels.
* @public
*/
export declare enum ErrorSeverity {
Fatal = "fatal",
Error = "error",
Warning = "warning",
Info = "info"
}
/**
* Custom error class thrown by the Flex SDK with structured error codes and metadata.
* @public
*/
export declare class FlexSdkError extends Error {
constructor(errorCode: ErrorCode, metadata?: FlexSdkErrorMetadata, details?: string, cause?: unknown);
/**
* Error code
* @readonly
*
* @type {ErrorCode}
*/
get code(): ErrorCode;
/**
* Detailed information about what caused the error
* @readonly
*
* @type {string | undefined}
*/
get details(): string | undefined;
/**
* Gets the metadata about the error
* @returns
*
* @readonly
*/
get metadata(): FlexSdkErrorMetadata;
}
/**
* Additional context attached to FlexSdkError instances.
* @public
*/
export declare interface FlexSdkErrorMetadata {
module?: string;
resourceSid?: string;
severity: ErrorSeverity;
source?: string;
translatedErrorCode?: ErrorCode;
unhandled?: boolean;
}
/**
* Returns VoiceCall object associated with the provided task.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task.
* @param options - Optional configuration parameters, containing an optional custom voice Device.
*
* @returns A promise that resolves to a `VoiceCall` object, representing the linked call.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToGetCallByTask}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.TaskNotVoiceTask}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { GetCallByTask } from "@twilio/flex-sdk/actions/Voice";
*
* async function getCallByTask() {
* const client = await createClient("SDK_TOKEN");
* const getCallByTask = new GetCallByTask("WTXXX");
* const voiceCall = await client.execute(getCallByTask);
* return voiceCall;
* }
* ```
*
* @public
*/
export declare class GetCallByTask implements Action> {
constructor(taskSid: string, options?: GetCallByTaskOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface GetCallByTaskOptions {
voiceDevice?: Device;
}
/**
* The URL endpoint to play when the participant is on hold and the HTTP method for the hold music URL
* @public
*/
export declare interface HoldCallOptions {
holdMusicUrl?: string;
holdMusicMethod?: string;
}
/**
* Puts a voice task participant on hold.
* @category Actions
*
* @param targetParticipantSid - The unique identifier (SID) of the participant to be held. Can be either a worker SID or participant SID.
* @param taskSid - The unique identifier (SID) of the task to hold the participant in.
* @param options - Optional configuration parameters for customizing the participant holding process.
*
* @returns A promise that resolves when the participant is successfully held.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToHoldExternalParticipant}
* - {@link ErrorCode.FailedToHoldWorkerParticipant}
* - {@link ErrorCode.FailedToHoldVoiceParticipant}
* - {@link ErrorCode.WorkerCannotHoldReservation}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.ParticipantNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { HoldVoiceParticipant } from "@twilio/flex-sdk/actions/Voice";
*
* async function holdVoiceParticipant() {
* const client = await createClient("SDK_TOKEN");
* const holdVoiceParticipantAction = new HoldVoiceParticipant(
* "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
* "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
* );
* await client.execute(holdVoiceParticipantAction);
* }
* ```
*
* @public
*/
export declare class HoldVoiceParticipant implements Action> {
constructor(targetParticipantSid: string, taskSid: string, options?: HoldVoiceParticipantOptions);
run(ctx: {}): Promise;
}
/**
* Configuration options for holding a participant in a task.
* @public
*/
export declare interface HoldVoiceParticipantOptions {
/**
* The URL of the hold music to play to the participant.
*/
holdMusicUrl?: string;
/**
* The HTTP method to use when fetching the hold music.
*/
holdMusicMethod?: string;
}
/**
* Kicks a participant from a task.
* @category Actions
*
* @param targetParticipantSid - The unique identifier (SID) of the participant to be kicked, can be either worker SID or participant SID.
* @param taskSid - The unique identifier (SID) of the task to kick the participant from.
*
* @returns A promise that resolves when the participant is successfully kicked.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedSelfKick}
* - {@link ErrorCode.FailedToKickVoiceParticipant}
* - {@link ErrorCode.InvalidParticipantSid}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.ParticipantNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { KickVoiceParticipant } from "@twilio/flex-sdk/actions/Voice";
*
* async function kickVoiceParticipant() {
* const client = await createClient("SDK_TOKEN");
* const kickVoiceParticipant = new KickVoiceParticipant("UTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* await client.execute(kickVoiceParticipant);
* }
* ```
*
* @public
*/
export declare class KickVoiceParticipant implements Action> {
constructor(targetParticipantSid: string, taskSid: string);
run(ctx: {}): Promise;
}
/**
* Media channel type
* @public
*/
export declare enum MediaChannelType {
Email = "email",
Sms = "sms",
WhatsApp = "whatsapp",
Web = "web",
Voice = "voice",
Messenger = "messenger",
Chat = "chat",
Gbm = "gbm",
Video = "video"
}
/**
* Media properties
* @public
*/
export declare type MediaProperties = {
[key: string]: any;
};
/**
* Monitors a provided ongoing call of another agent.
* @category Actions
*
* @param taskSid - The taskSid of the task to monitor the call for.
* @param reservationSid - The reservationSid of the task to monitor the call for.
* @param options - Optional configuration parameters for customizing the monitor call process.
*
* @returns A promise that resolves to a `VoiceCall` object, representing the call.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.SupervisorAlreadyMonitoringCall}
* - {@link ErrorCode.FailedToMonitorCall}
* - {@link ErrorCode.WorkerNotInitialized}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { MonitorCall } from "@twilio/flex-sdk/actions/Voice";
*
* async function example() {
* const client = await createClient("SDK_TOKEN");
* const monitorCall = new MonitorCall("WTXXXXXXXXXXXXXXXXXXXXXXXXX", "WRXXXXXXXXXXXXXXXXXXXXXXXXX");
* const call = await client.execute(monitorCall);
* }
* ```
*
* @public
*/
export declare class MonitorCall implements Action> {
constructor(taskSid: string, reservationSid: string, options?: MonitorCallOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface MonitorCallOptions {
extraParams?: Record;
voiceDevice?: Device;
}
/**
* Call properties for add voice participant
* @public
*/
export declare type ParticipantCallProperties = {
timeout: number;
statusCallBack: ParticipantCallStatusProperties;
record: ParticipantCallRecordProperties;
sip: ParticipantSipProperties;
};
/**
* Call record properties for add voice participant
* @public
*/
export declare type ParticipantCallRecordProperties = {
url: string;
method: 'GET' | 'POST';
channels: string;
};
/**
* Enumeration of values representing the state of a participant's call.
* @public
*/
export declare enum ParticipantCallStatus {
Init = "init",
Queued = "queued",
Connecting = "connecting",
Connected = "connected",
Complete = "complete",
Failed = "failed",
Busy = "busy",
NoAnswer = "no-answer",
Ringing = "ringing",
InProgress = "in-progress",
Completed = "completed",
Canceled = "canceled"
}
/**
* Call status properties for add voice participant
* @public
*/
export declare type ParticipantCallStatusProperties = {
url: string;
method: 'GET' | 'POST';
events: string;
};
/**
* Data of a participant received from events
* @public
*/
export declare type ParticipantEventData = {
/**
* The sid of the participant (UTxxx)
*/
participant_sid: string;
/**
* The type of the participant
*/
type: ParticipantType;
/**
* The type of the channel
*/
channel_type: MediaChannelType;
/**
* The sid of the channel (UOxxx)
*/
channel_sid: string;
/**
* The sid of the interaction (KDxxx)
*/
interaction_sid: string;
/**
* The routing properties of the participant
*/
routing_properties: RoutingData | null;
/**
* Media properties of the participant
*/
media_properties: MediaProperties | null;
};
/**
* Participant level in an email
* @public
*/
export declare enum ParticipantLevel {
To = "to",
CC = "cc"
}
/**
* Response for the participant endpoint request
* @public
*/
export declare type ParticipantResponse = {
/**
* The identifier of the participant who is added to the channel
*/
sid: string;
/**
* The channel sid of the channel where the participant is added
*/
channel_sid: string;
/**
* The identifier of the interaction where the participant is added
*/
interaction_sid: string;
/**
* Optional media properties of the participant
*/
media_properties: MediaProperties | null;
};
/**
* Sip properties for add voice participant
* @public
*/
export declare type ParticipantSipProperties = {
username: string;
password: string;
};
/**
* Type of the participant, 'agent', 'customer', 'supervisor', 'external' or 'unknown'
* @public
*/
export declare enum ParticipantType {
Agent = "agent",
Customer = "customer",
Supervisor = "supervisor",
External = "external",
Unknown = "unknown"
}
/**
* Enumeration of reasons why a participant left a voice conference.
* @public
*/
export declare enum ReasonParticipantLeft {
ConferenceEndedViaAPI = "conference_ended_via_api",
ModeratorEndedConference = "moderator_ended_conference",
ParticipantUpdatedViaApi = "participant_updated_via_api",
ParticipantHungUp = "participant_hung_up",
ParticipantAddFailed = "participant_add_failed"
}
/**
* Data used for routing
* @public
*/
export declare type RoutingData = {
/**
* Sid of a task this routing data corresponds to (WTxxx)
*/
task_sid: string;
/**
* Sid of a worker this routing data corresponds to (WKxxx)
*/
worker_sid?: string;
/**
* Sid of a reservation this routing data corresponds to (WRxxx)
*/
reservation_sid?: string;
};
/**
* Routing properties of one participant
* @public
*/
export declare class RoutingProperties {
/**
* Sid of a task these routing properties correspond to (WTxxx)
*/
readonly taskSid: string;
/**
* Sid of a worker these routing properties correspond to (WKxxx)
*/
readonly workerSid?: string;
/**
* Sid of a reservation these routing properties correspond to (WRxxx)
*/
readonly reservationSid?: string;
constructor(routingData: RoutingData);
}
/**
* Aggregate connection state of the Flex SDK, combining network and all initialized SDKs.
* SDK fields are `"notInitialized"` when that SDK has not been started yet.
* @public
*/
export declare interface SdkConnectionState {
overall: ConnectionState;
network: "connected" | "disconnected";
conversations: ConnectionState;
voice: ConnectionState;
taskrouter: ConnectionState;
}
/**
* Initiates an outbound voice call to a specified phone number.
*
* @category Actions
*
* @param toNumber - The phone number to call.
* @param options - Optional configuration parameters for customizing the outbound call process.
*
* @returns A promise that resolves to a `VoiceCall` object, representing the outbound call.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FromNumberRequired}
* - {@link ErrorCode.TaskQueueSidRequired}
* - {@link ErrorCode.WorkflowSidRequired}
* - {@link ErrorCode.WorkerOfflineOutboundCallCancelled}
* - {@link ErrorCode.OutboundCallingDisabled}
* - {@link ErrorCode.InboundCallPendingOutboundCancelled}
* - {@link ErrorCode.InboundCallAcceptedOutboundCancelled}
* - {@link ErrorCode.NoAudioInputDeviceAvailable}
* - {@link ErrorCode.IncomingCallTimeout}
* - {@link ErrorCode.FailedToCreateTask}
* - {@link ErrorCode.FailedToCreateVoiceTaskReservation}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.MissingRequiredParameter}
* - {@link ErrorCode.TaskrouterOfflineActivitySidNotConfigured}
* - {@link ErrorCode.FailedToCreateConference}
*
* @example
* ```ts
* import { createClient, Reservation } from "@twilio/flex-sdk";
* import { StartOutboundCall, StartOutboundCallOptions } from "@twilio/flex-sdk/actions/Voice";
*
* async function startOutboundCall() {
* const client = await createClient("SDK_TOKEN");
* const reservationCanceledHandler = (reservation: Reservation) => {
* console.log(
* `Reservation canceled with reason https://www.twilio.com/docs/api/errors/${reservation.canceledReasonCode}`
* );
* reservation.off("canceled", reservationCanceledHandler);
* };
* const startOutboundCallOptions: StartOutboundCallOptions = {
* reservationEventListeners: {
* canceled: reservationCanceledHandler
* }
* };
* const startOutboundCallAction = new StartOutboundCall("+15555555555", startOutboundCallOptions);
* const call = await client.execute(startOutboundCallAction);
* }
* ```
*
* @public
*/
export declare class StartOutboundCall implements Action> {
constructor(toNumber: string, options?: StartOutboundCallOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface StartOutboundCallOptions {
fromNumber?: string;
workflowSid?: string;
taskQueueSid?: string;
attributesForTaskCreation?: object;
conferenceOptions?: Partial;
voiceDevice?: Device;
reservationEventListeners?: Partial;
/**
* Bring Your Own Carrier ([BYOC](https://www.twilio.com/docs/voice/bring-your-own-carrier-byoc)) SID to be associated with the outbound call task.
*/
byocSid?: string;
}
/**
* Transfers a voice task to a target worker or a queue.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be transferred.
* @param to - The unique identifier (SID) of the worker or the queue to transfer the task to.
* @param options - Optional configuration parameters for customizing the task transfer process.
*
* @returns A promise that resolves to a `Task` object, representing the transferred task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.VoiceTaskTransferAlreadyInitiated}
* - {@link ErrorCode.WorkerCannotTransferVoiceTaskFromDifferentWorker}
* - {@link ErrorCode.FailedToStartVoiceTaskTransfer}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.TaskNotVoiceTask}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { StartVoiceTaskTransfer } from "@twilio/flex-sdk/actions/Voice";
*
* async function transferVoiceTask() {
* const client = await createClient("SDK_TOKEN");
* const startVoiceTaskTransfer = new StartVoiceTaskTransfer("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const transferredTask = await client.execute(startVoiceTaskTransfer);
* return transferredTask;
* }
* ```
*
* @public
*/
export declare class StartVoiceTaskTransfer implements Action> {
constructor(taskSid: string, to: string, options?: TransferTaskOptions);
run(ctx: {}): Promise;
}
/**
* Enumeration of events that trigger participant status changes during voice calls.
* @public
*/
export declare enum StatusCallbackEvent {
ConferenceStart = "conference-start",
ConferenceEnd = "conference-end",
ParticipantJoin = "participant-join",
ParticipantLeave = "participant-leave",
ParticipantMute = "participant-mute",
ParticipantUnmute = "participant-unmute",
ParticipantModify = "participant-modify",
ParticipantSpeechStart = "participant-speech-start",
ParticipantSpeechStop = "participant-speech-stop",
ParticipantHold = "participant-hold",
ParticipantUnhold = "participant-unhold"
}
/**
* A wrapper for the TaskRouter Supervisor class.
* @public
*/
export declare class Supervisor extends Supervisor_2 {
constructor(token: string, options?: WorkerOptions_2);
}
/**
* Union of the {@link VoiceTaskParticipant} and {@link ConversationTaskParticipant} types.
* @public
*/
export declare type TaskParticipant = VoiceTaskParticipant | ConversationTaskParticipant;
/**
* @public
*/
export declare interface TransferTaskOptions extends TransferOptions {
}
/**
* Removes a participant from hold status in a task.
* @category Actions
*
* @param targetParticipantSid - The unique identifier (SID) of the participant to be unheld. Can be either a worker SID or participant SID.
* @param taskSid - The unique identifier (SID) of the task to unhold the participant in.
*
* @returns A promise that resolves when the participant is successfully unheld.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToUnholdExternalParticipant}
* - {@link ErrorCode.FailedToUnholdWorkerParticipant}
* - {@link ErrorCode.FailedToUnholdVoiceParticipant}
* - {@link ErrorCode.WorkerCannotUnholdReservation}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.ParticipantNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { UnholdVoiceParticipant } from "@twilio/flex-sdk/actions/Voice";
*
* async function unholdParticipant() {
* const client = await createClient("SDK_TOKEN");
* const unholdVoiceParticipant = new UnholdVoiceParticipant("WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* await client.execute(unholdVoiceParticipant);
* }
* ```
*
* @public
*/
export declare class UnholdVoiceParticipant implements Action> {
constructor(targetParticipantSid: string, taskSid: string);
run(ctx: {}): Promise;
}
/**
* Interface for controlling voice calls with mute, hold, disconnect, and recording capabilities.
* @public
*/
export declare interface VoiceCall {
/**
* @ignore
*/
call: Call | null;
/**
* @ignore
*/
device: Device;
/**
* Check if current call (if there is one) is on hold.
* @returns - A promise that resolves to a boolean indicating whether the call is on hold.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.VoiceReservationNotLiveCall}
* - {@link ErrorCode.CallInstanceUndefined}
* - {@link ErrorCode.VoiceReservationNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
*
* const isOnHold: boolean = await voiceCall.isOnHold();
* console.log(`Call ${isOnHold ? "is on hold" : "is not on hold"}`)
* ```
*/
isOnHold(): Promise;
/**
* Hang up current call (if there is one).
* @returns
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToDisconnectCall}
* - {@link ErrorCode.CallInstanceUndefined}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
*
* await voiceCall.disconnect();
* ```
*/
disconnect(): Promise;
/**
* Is current call muted
* @returns - A boolean indicating whether the call is muted
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.CallInstanceUndefined}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
*
* const isMuted: boolean = voiceCall.isMuted();
* console.log(`Call ${isMuted ? "is muted" : "is not muted"}`)
* ```
*/
isMuted(): boolean | undefined;
/**
* Mute current call
* @returns
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.CallInstanceUndefined}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
* voiceCall.mute();
*
* const isMuted: boolean = voiceCall.isMuted();
* console.log(`Call ${isMuted ? "is muted" : "is not muted"}`)
* ```
*/
mute(): void;
/**
* Unmute current call
* @returns
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.CallInstanceUndefined}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
* voiceCall.unmute();
*
* const isMuted: boolean = voiceCall.isMuted();
* console.log(`Call ${isMuted ? "is muted" : "is not muted"}`)
* ```
*/
unmute(): void;
/**
* Hold current call (if there is one).
* @param options - Options to specify hold music URL and HTTP method
*
* @returns - A promise that resolves to a `Task` object, representing the held task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.WorkerCannotHoldReservation}
* - {@link ErrorCode.CallInstanceUndefined}
* - {@link ErrorCode.FailedToHoldCall}
* - {@link ErrorCode.VoiceReservationNotFound}
* - {@link ErrorCode.WorkerNotInitialized}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
*
* await voiceCall.hold({ holdMusicUrl: "holdMusicUrl", holdMusicMethod: "GET" });
* ```
*/
hold(options?: HoldCallOptions): Promise;
/**
* Unhold current call (if there is one).
* @returns - A promise that resolves to a `Task` object, representing the unheld task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.WorkerCannotUnholdReservation}
* - {@link ErrorCode.CallInstanceUndefined}
* - {@link ErrorCode.FailedToUnholdCall}
* - {@link ErrorCode.VoiceReservationNotFound}
* - {@link ErrorCode.WorkerNotInitialized}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX", { fromNumber: "+1XXX", workflowSid: "WWXXX", taskQueueSid: "WQXXX"});
*
* const voiceCall = await client.execute(startOutboundCall);
*
* // Call is not on hold by default so to unhold, it is needed to hold first
* await call.hold("holdMusicUrl", "GET");
* await call.unhold();
* ```
*/
unhold(): Promise;
/**
* Resume recording current conference. This method will only resume an existing recording, it won't start a new one.
* @returns
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.NoConferenceSidFoundInTaskAttributes}
* - {@link ErrorCode.NoActiveRecordingToResume}
* - {@link ErrorCode.FailedToResumeRecording}
* - {@link ErrorCode.CallInstanceUndefined}
* - {@link ErrorCode.VoiceReservationNotFound}
* - {@link ErrorCode.WorkerNotInitialized}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX");
*
* const voiceCall = await client.execute(startOutboundCall);
*
* await voiceCall.resumeRecording();
* ```
*/
resumeRecording(): Promise;
/**
* Pause recording current conference (if there is one).
* @param pauseBehaviour - The behaviour to use when pausing the recording. Can be either "silence" or "skip". Default is "silence".
*
* @returns
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.NoConferenceSidFoundInTaskAttributes}
* - {@link ErrorCode.NoActiveRecordingToPause}
* - {@link ErrorCode.FailedToPauseRecording}
* - {@link ErrorCode.CallInstanceUndefined}
* - {@link ErrorCode.VoiceReservationNotFound}
* - {@link ErrorCode.WorkerNotInitialized}
*
* @example
* ```ts
* import { createClient, StartOutboundCall } from "@twilio/flex-sdk";
*
* const client = await createClient("SDK_TOKEN");
* const startOutboundCall = new StartOutboundCall("+1XXX");
*
* const voiceCall = await client.execute(startOutboundCall);
*
* await voiceCall.pauseRecording("silence");
* ```
*/
pauseRecording(pauseBehaviour?: "silence" | "skip"): Promise;
}
/**
* Enumeration of voice event names that the Flex SDK client can listen to.
* @public
*/
export declare enum VoiceClientEvent {
Error = "error",
Incoming = "incoming",
Destroyed = "destroyed",
TokenWillExpire = "tokenWillExpire",
Unregistered = "unregistered"
}
/**
* Media properties specific to voice participants.
* @public
*/
export declare type VoiceMediaProperties = {
accountSid: string;
callSid: string;
coaching: boolean;
conferenceSid: string;
endConferenceOnExit: boolean;
friendlyName: string;
hold: boolean;
muted: boolean;
sequenceNumber: number;
timestamp: string;
startConferenceOnEnter: boolean;
statusCallbackEvent?: StatusCallbackEvent;
participantCallStatus?: ParticipantCallStatus;
reasonParticipantLeft?: ReasonParticipantLeft;
from?: string;
to?: string;
} & MediaProperties;
/**
* Extends {@link BaseParticipant} with properties specific to voice participants.
* @public
*/
export declare type VoiceTaskParticipant = BaseParticipant & {
readonly channelType: MediaChannelType.Voice;
/**
* Media properties of the participant
*/
readonly mediaProperties?: VoiceMediaProperties | null;
/**
* Is participant on hold
*/
readonly isOnHold: boolean;
};
export { }