///
import { ConferenceOptions } from 'twilio-taskrouter';
import { RejectOptions } from 'twilio-taskrouter';
import { Reservation } from 'twilio-taskrouter';
import { Task } from 'twilio-taskrouter';
/**
* Accepts a task and reserves it for the current worker.
* @category Actions
*
* @remarks
* For **voice tasks**, you must register a `VoiceClientEvent` listener with `AddVoiceEventListener` before running this action.
* If this is not done, accepting the task may fail.
*
* @param taskSid - The unique identifier (SID) of the task to be accepted.
* @param options - Optional configuration parameters for customizing the task acceptance process.
*
* @returns A promise that resolves to a `Reservation` and a `Task` object representing the accepted task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.FailedToAcceptReservation}
* - {@link ErrorCode.FailedToCreateConference}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { AcceptTask } from "@twilio/flex-sdk/actions/Task";
*
* async function acceptTask() {
* const client = await createClient("SDK_TOKEN");
* const acceptTask = new AcceptTask("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const { task, reservation } = await client.execute(acceptTask);
* return { task, reservation };
* }
* ```
*
* @public
*/
export declare class AcceptTask implements Action> {
constructor(taskSid: string, options?: AcceptTaskOptions);
run(ctx: {}): Promise<{
task: Task;
reservation: Reservation;
}>;
}
/**
* @public
*/
export declare interface AcceptTaskOptions {
conferenceOptions?: ConferenceOptions;
}
/**
* 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 task participant event listener.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task.
* @param eventName - The event name (e.g. participantAdded).
* @param listener - The event listener function.
*
* @returns A promise that resolves to an object containing the unsubscribe function to remove the listener.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { AddTaskParticipantListener } from "@twilio/flex-sdk/actions/Task";
*
* async function addTaskParticipantListener() {
* const client = await createClient("SDK_TOKEN");
*
* const addTaskParticipantListener = new AddTaskParticipantListener(
* "WTxxx",
* "participantAdded",
* (task, participant) => {
* console.log(`Participant added: ${participant.sid} to task ${task.sid}`);
* }
* );
* const { unsubscribe } = await client.execute(addTaskParticipantListener);
* return unsubscribe;
* }
* ```
*
* @public
*/
export declare class AddTaskParticipantListener implements Action> {
constructor(taskSid: string, eventName: T, listener: TaskParticipantEvent[T]);
run(ctx: {}): Promise<{
unsubscribe: () => Task;
}>;
}
/**
* @public
*/
export declare interface AddTaskParticipantListenerResponse {
/**
* Unsubscribe function to remove the event listener.
*/
unsubscribe: () => void;
}
/**
* 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;
}
/**
* Completes a task that is either pending or assigned.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be completed.
*
* @returns A promise that resolves to a `Task` object, representing the completed task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToRemoveParticipant}
* - {@link ErrorCode.FailedToCompleteReservation}
* - {@link ErrorCode.WorkerParticipantNotFoundForTask}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { CompleteTask } from "@twilio/flex-sdk/actions/Task";
*
* async function completeTask() {
* const client = await createClient("SDK_TOKEN");
*
* const completeTask = new CompleteTask("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const completedTask = await client.execute(completeTask);
* return completedTask;
* }
* ```
*
* @public
*/
export declare class CompleteTask implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* 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 task.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be ended.
*
* @returns A promise that resolves to a `Reservation` and a `Task` object, representing the ended task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToEndTask}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { EndTask } from "@twilio/flex-sdk/actions/Task";
*
* async function endTask() {
* const client = await createClient("SDK_TOKEN");
* const endTask = new EndTask("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const { task, reservation } = await client.execute(endTask);
* return { task, reservation };
* }
* ```
*
* @public
*/
export declare class EndTask implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise<{
task: Task;
reservation: Reservation;
}>;
}
/**
* 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;
}
/**
* Retrieves channels for a specified task, providing interaction and channel SIDs.
* @category Actions
*
* @param taskSid - The SID of the task to retrieve channels for.
*
* @returns A promise that resolves with an array of channel objects containing interaction and channel SIDs.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.FailedToGetChannelsForTask}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { GetChannelsForTask } from "@twilio/flex-sdk/actions/Task";
*
* async function getChannelsForTask() {
* const client = await createClient("SDK_TOKEN");
* const action = new GetChannelsForTask("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const channels = await client.execute(action);
* console.log(channels[0].interactionSid, channels[0].sid);
* }
* ```
*
* @public
*/
export declare class GetChannelsForTask implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* Retrieves all participants attached to a task.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task.
*
* @returns A promise that resolves to an array of `Participant` objects.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
* - {@link ErrorCode.FailedToRetrieveTaskParticipants}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { GetTaskParticipants } from "@twilio/flex-sdk/actions/Task";
*
* async function getTaskParticipants() {
* const client = await createClient("SDK_TOKEN");
* const getTaskParticipants = new GetTaskParticipants("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const participants = await client.execute(getTaskParticipants);
* return participants;
* }
* ```
*
* @public
*/
export declare class GetTaskParticipants implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare type GetTaskParticipantsResponse = Array;
/**
* 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;
};
/**
* 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"
}
/**
* 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"
}
/**
* 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"
}
/**
* Rejects a task for the current worker.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be rejected.
* @param options - Optional parameters for rejecting the task, such as the activity SID to set after rejection.
*
* @returns A promise that resolves to a `Reservation` and a `Task` object representing the rejected task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToRejectReservation}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { RejectTask } from "@twilio/flex-sdk/actions/Task";
*
* async function rejectTask() {
* const client = await createClient("SDK_TOKEN");
* const rejectTask = new RejectTask("WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const { task, reservation } = await client.execute(rejectTask);
* return { task, reservation };
* }
* ```
*
* @public
*/
export declare class RejectTask implements Action> {
constructor(taskSid: string, options?: RejectTaskOptions);
run(ctx: {}): Promise<{
task: Task;
reservation: Reservation;
}>;
}
/**
* @public
*/
export declare interface RejectTaskOptions extends RejectOptions {
}
/**
* 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);
}
/**
* Sets attributes for a task.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to set attributes for.
* @param attributes - An object containing attributes to set for the task.
* @param options - Optional configuration parameters for customizing the attribute setting process.
*
* @returns A promise that resolves to a Task object, representing the updated task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToSetTaskAttributes}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { SetTaskAttributes } from "@twilio/flex-sdk/actions/Task";
*
* async function setTaskAttributes() {
* const client = await createClient("SDK_TOKEN");
* const setTaskAttributesAction = new SetTaskAttributes(
* "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
* { key: "value" }
* );
* const updatedTask = await client.execute(setTaskAttributesAction);
* return updatedTask;
* }
* ```
*
* @public
*/
export declare class SetTaskAttributes implements Action> {
constructor(taskSid: string, attributes: Record, options?: SetTaskAttributesOptions);
run(ctx: {}): Promise;
}
/**
* @public
*/
export declare interface SetTaskAttributesOptions {
mergeExisting?: boolean;
}
/**
* 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"
}
/**
* Channel information returned by the GetChannelsForTask action.
* @public
*/
export declare interface TaskChannel {
sid: string;
interactionSid: string;
type: string;
status: string;
mediaSid: string;
}
/**
* Union of the {@link VoiceTaskParticipant} and {@link ConversationTaskParticipant} types.
* @public
*/
export declare type TaskParticipant = VoiceTaskParticipant | ConversationTaskParticipant;
/**
* @public
*/
export declare interface TaskParticipantEvent {
participantAdded: (task: Task, participant: TaskParticipant) => void;
participantRemoved: (task: Task, participant: TaskParticipant) => void;
participantModified: (task: Task, participant: TaskParticipant) => void;
participantAddFailed: (task: Task, participant: TaskParticipant) => void;
participantRemoveFailed: (task: Task, participant: TaskParticipant) => void;
participantModifyFailed: (task: Task, participant: TaskParticipant) => void;
}
/**
* @public
*/
export declare interface TaskReservation {
task: Task;
reservation: Reservation;
}
/**
* 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;
};
/**
* Wraps up a task that is either pending or assigned.
* @category Actions
*
* @param taskSid - The unique identifier (SID) of the task to be completed.
*
* @returns A promise that resolves to a `Reservation` and a `Task` object representing the completed task.
*
* @throws {@link FlexSdkError} with the following error code(s):
* - {@link ErrorCode.FailedToWrapUpReservation}
* - {@link ErrorCode.WorkerNotInitialized}
* - {@link ErrorCode.TaskReservationNotFound}
*
* @example
* ```ts
* import { createClient } from "@twilio/flex-sdk";
* import { WrapUpTask } from "@twilio/flex-sdk/actions/Task";
*
* async function wrapUpTask() {
* const client = await createClient("SDK_TOKEN");
* const wrapUpTask = new WrapUpTask("TSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
* const { task, reservation } = await client.execute(wrapUpTask);
* return { task, reservation };
* }
* ```
*
* @public
*/
export declare class WrapUpTask implements Action> {
constructor(taskSid: string);
run(ctx: {}): Promise<{
task: Task;
reservation: Reservation;
}>;
}
export { }