import { ActivityOptions } 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; } /** * 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; } /** * Sets attributes for the worker. * @category Actions * * @param attributes - An object containing attributes to set for the worker. * @param options - Optional configuration parameters for customizing the attribute setting process. * * @returns A promise that resolves when the attributes are successfully set. * * @throws {@link FlexSdkError} with the following error code(s): * - {@link ErrorCode.FailedToSetCurrentWorkerAttributes} * - {@link ErrorCode.WorkerNotInitialized} * * @example * ```ts * import { createClient } from "@twilio/flex-sdk"; * import { SetAttributes } from "@twilio/flex-sdk/actions/Worker"; * * async function setWorkerAttributes() { * const client = await createClient("SDK_TOKEN"); * const setAttributesAction = new SetAttributes({ key: "value" }); * await client.execute(setAttributesAction); * } * ``` * * @public */ export declare class SetAttributes implements Action> { constructor(attributes: Record, options?: SetAttributesOptions); run(ctx: {}): Promise; } /** * @public */ export declare interface SetAttributesOptions { mergeExisting?: boolean; } /** * Sets the current activity for the worker. * @category Actions * * @param activitySid - The unique identifier (SID) of the activity to be set as the current activity. * @param options - Optional configuration parameters for customizing the activity setting process. * * @returns A promise that resolves when the current activity is successfully set. * * @throws {@link FlexSdkError} with the following error code(s): * - {@link ErrorCode.FailedToSetCurrentWorkerActivityDueToPendingReservations} * - {@link ErrorCode.FailedToSetCurrentWorkerActivity} * - {@link ErrorCode.WorkerNotInitialized} * * @example * ```ts * import { createClient, SetCurrentActivity } from "@twilio/flex-sdk"; * * async function setCurrentActivity() { * const client = await createClient("SDK_TOKEN"); * const worker = await client.getWorker(); * * // Activities are accessible via Worker.activities property (Map of activitySID to Activity) * const activities = Array.from(worker.activities.values()); * const targetActivity = activities.find(activity => activity.name === "Available") || activities[0]; * * console.log(`Setting worker activity to "${targetActivity.name}" (${targetActivity.sid})`); * * const setCurrentActivityAction = new SetCurrentActivity(targetActivity.sid); * await client.execute(setCurrentActivityAction); * } * ``` * * @public */ export declare class SetCurrentActivity implements Action> { constructor(activitySid: string, options?: SetCurrentActivityOptions); run(ctx: {}): Promise; } /** * @public */ export declare interface SetCurrentActivityOptions { activityUpdateOptions?: ActivityOptions; } export { }