@twilio/flex-ui
Version:
Twilio Flex UI
316 lines (315 loc) • 11.5 kB
TypeScript
import { ParticipantLevel } from "@twiliointernal/cbm-sdk";
import { CallOptions, DequeueOptions, RedirectOptions, ReservationParticipantOptions, TaskParticipantOptions } from "twilio-taskrouter";
import { IParticipant, ITask, WorkerAttributes } from "../models";
import { ConferenceParticipant } from "../state/Conferences/ConferenceParticipant";
/**
* @package
* @typedef WorkerActionPayload
* @property {ITask} [task] - targeted task object. Either this or sid property is required
* @property {string} [sid] - targeted task object's sid. Either this or task property is required
* @memberof Actions
*/
export interface WorkerActionPayload {
task?: ITask;
sid?: string;
reason?: string;
agent?: IParticipant;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} TransferTaskPayload
* @property {string} targetSid - sid of the worker or the queue to be transferred to
* @property {any} [options] - transfer options (see [Taskrouter](https://www.twilio.com/docs/taskrouter) docs for options).
* @memberof Actions
*/
export interface TransferTaskPayload extends WorkerActionPayload {
targetSid: string;
options?: any;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} WorkerParticipantActionPayload
* @property {string} [targetSid] - sid of the participant (either this or participant has to be provided)
* @property {ConferenceParticipant} [participant] - participant object (either this or participant has to be provided)
* @property {string} [holdMusicUrl] - url of audio to play when on hold
* @property {string} [holdMusicMethod] - name of hold music method
* @since 2.0.0
* @memberof Actions
*/
export interface WorkerParticipantActionPayload extends WorkerActionPayload {
targetSid?: string;
participant?: ConferenceParticipant;
holdMusicUrl?: string;
holdMusicMethod?: string;
}
/**
* @package
* @typedef WorkerSetActivityPayload
* @property {boolean} [activityAvailable] if the activity is available
* @property {string} [activityName] name of activity
* @property {string} [activitySid] sid of activity
* @property {boolean} [options.rejectPendingReservations] if pending reservations should be rejected
* @memberof Actions
*/
export interface WorkerSetActivityPayload {
activityAvailable?: boolean;
activityName?: string;
activitySid?: string;
options?: {
rejectPendingReservations?: boolean;
};
}
/**
* @package
* @typedef WorkerSetWorkerActivityPayload
* @property {string} [workerSid] - sid of the worker
* @memberof WorkerActions
*/
export interface WorkerSetWorkerActivityPayload extends WorkerSetActivityPayload {
workerSid?: string;
}
/**
* @package
* @typedef WorkerLogoutPayload
* @property {boolean} [forceLogout] - supress an error in case offline activity cannot be set for the worker
* @property {string} [activitySid] - sid of the custom offline activity
* @memberof Actions
*/
export interface WorkerLogoutPayload {
forceLogout?: boolean;
activitySid?: string;
}
/**
* @private
*/
export interface DeprecatedWorkerLogoutPayload extends WorkerLogoutPayload {
activityName?: string;
}
/**
* @package
* @typedef WorkerAcceptTaskActionPayload
* @property {any} conferenceOptions conferenceOptions
* @memberof Actions
*/
export interface WorkerAcceptTaskActionPayload extends WorkerActionPayload {
conferenceOptions: any;
}
/**
* @package
* @typedef ToggleDTMFDialpadPayload
* @property {boolean} open if dialpad should be opened
* @memberof Actions
*/
export interface ToggleDTMFDialpadPayload extends WorkerActionPayload {
open?: boolean;
}
/**
* @package
* @typedef SetDTMFDialpadDigitsPayload
* @property {string} digits dialpad input
* @memberof Actions
*/
export interface SetDTMFDialpadDigitsPayload extends WorkerActionPayload {
digits: string;
}
/**
* @package
* @typedef SendDTMFDigitsPayload
* @property {string} digits dialpad input to send
* @memberof Actions
*/
export interface SendDTMFDigitsPayload extends WorkerActionPayload {
digits: string;
}
/**
* @package
* @typedef {Actions.StartOutboundEmailTaskPayload} StartOutboundEmailTaskPayload
* @property {string} destination - destination email address
* @property {string} [queueSid] - queue sid to assign for the task, if undefined it picks the default from service configuration.
* @property {string} [from] - a verified email address to be used as sender, if undefined it picks the default from service configuration.
* @property {string} [fromName] - the name for the email sender to be associated to the 'from' address
* @property {object} [taskAttributes] - custom attributes to set on task.
* @private
* @memberof Actions
*/
export interface StartOutboundEmailTaskPayload {
destination: string;
queueSid?: string;
from?: string;
fromName?: string;
taskAttributes?: object;
}
/**
* @package
* @typedef SetWorkerAttributesPayload
* @property {WorkerAttributes} [attributes] - Attributes for worker.
* @property {boolean} [mergeExisting=true] - Represents if new attributes are to be merged with the existing one
* @memberof Actions
*/
export interface SetWorkerAttributesPayload {
attributes: WorkerAttributes;
mergeExisting: boolean;
}
/**
* @package
* @typedef UpdateWorkerTokenPayload
* @property {string} token newToken
* @memberof Actions
*/
export interface UpdateWorkerTokenPayload {
token: string;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} SetTaskAttributesPayload
* @property {object} [attributes] - Attributes for the task.
* @property {boolean} [mergeExisting] - Represents if new attributes are to be merged with the existing one
* @memberof Actions
*/
export interface SetTaskAttributesPayload extends WorkerActionPayload {
attributes: Record<string, any>;
mergeExisting: boolean;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} UpdateWorkerParticipantPayload
* @property {ReservationParticipantOptions} options - See (ReservationParticipantOptions)(https://twilio.github.io/twilio-taskrouter.js/Reservation.html#.ParticipantOptions__anchor) for more info.
* @memberof Actions
*/
export interface UpdateWorkerParticipantPayload extends WorkerActionPayload {
options?: ReservationParticipantOptions;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} UpdateCustomerParticipantPayload
* @property {TaskParticipantOptions} options - See [TaskPartipantOptions](https://twilio.github.io/twilio-taskrouter.js/Task.html#.ParticipantOptions__anchor) for more info.
* @memberof Actions
*/
export interface UpdateCustomerParticipantPayload extends WorkerActionPayload {
options?: TaskParticipantOptions;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} IssueCallToWorkerPayload
* @property {string} callerId - The caller id for the call to a Worker.
* @property {string} twiMLUrl - A valid TwiML URI that is executed on the answering Worker's leg.
* @property {CallOptions} options - See [CallOptions](https://twilio.github.io/twilio-taskrouter.js/Reservation.html#.CallOptions__anchor) for more info.
* @memberof Actions
*/
export interface IssueCallToWorkerPayload extends WorkerActionPayload {
callerId: string;
twiMLUrl: string;
options?: CallOptions;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} DequeueTaskPayload
* @property {DequeueOptions} options - See [DequeueOptions](https://twilio.github.io/twilio-taskrouter.js/Reservation.html#.DequeueOptions__anchor) for more info.
* @memberof Actions
*/
export interface DequeueTaskPayload extends WorkerActionPayload {
options?: DequeueOptions;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} IssueCallToWorkerPayload
* @property {string} callSid - The sid of the Call to redirect.
* @property {string} twiMLUrl - A valid TwiML URI that is executed on the Caller's leg upon redirecting.
* @property {RedirectOptions} [options] - See [RedirectOptions](https://twilio.github.io/twilio-taskrouter.js/Reservation.html#.RedirectOptions__anchor) for more info.
* @memberof Actions
*/
export interface RedirectCallTaskPayload extends WorkerActionPayload {
callSid: string;
twiMLUrl: string;
options?: RedirectOptions;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} AddEmailParticipantPayload
* @property {string} conversationSid - The sid of the conversations
* @property {string} email - The email of the participant to be added
* @property {"to"|"cc"} level - Level of the participant to be added
* @property {string} [name] - Name of the participant to be added
* @memberof Actions
* @private
*/
export interface AddEmailParticipantPayload {
conversationSid: string;
email: string;
level: ParticipantLevel;
name?: string;
}
/**
* @package
* @typedef {Actions.WorkerActionPayload} RemoveEmailParticipantPayload
* @property {string} conversationSid - The sid of the conversations
* @property {string} participantSid - The conversations sid of the participant to be removed
* @memberof Actions
* @private
*/
export interface RemoveEmailParticipantPayload {
conversationSid: string;
participantSid: string;
}
/**
* Predefined UI actions
* @package
* @interface Actions
* @category Actions
* @menuorder 200
*/
export declare class WorkerActions {
static registerActions(): void;
private static setWorkerAttributes;
private static updateWorkerToken;
private static setTaskAttributes;
private static dequeueTask;
private static redirectCallTask;
private static issueCallToWorker;
private static updateWorkerParticipant;
private static updateCustomerParticipant;
private static blockActionUntilReservationEvent;
private static sendTrackingTaskTransferEvent;
private static sendTrackingTaskCompletionEvent;
private static acceptTask;
private static rejectTask;
private static endVoiceTask;
private static completeTask;
private static wrapupTask;
private static selectTask;
private static setActivity;
private static setWorkerActivity;
private static transferTask;
private static cancelTransfer;
private static kickParticipant;
private static holdParticipant;
private static unholdParticipant;
private static toggleDTMFDialpad;
private static sendDTMFDigitsToCall;
private static setDTMFDialpadDigits;
private static updateWorkerActionPayload;
private static updateWorkerParticipantActionPayload;
private static updateAcceptTaskPayload;
private static updateWorkerSetActivityPayload;
private static updateWorkerSetWorkerActivityPayload;
private static logout;
private static startOutboundEmailTask;
static startOutboundTask(payload: StartOutboundTaskPayload): Promise<void>;
private static addEmailParticipant;
private static removeEmailParticipant;
}
export interface StartOutboundTaskPayload {
destination: string;
from: string;
workflowSid: string;
queueSid: string;
options: {
attributes: Record<string, any>;
taskChannelUniqueName?: string;
mediaChannelType?: string;
fromName?: string;
};
}
export declare const isValidTaskPayload: (task: ITask) => (payload: any) => boolean;
export declare const isValidWorkerActionPayload: (task: ITask) => (payload: any) => boolean;
export declare const isValidWorkerParticipantActionPayload: (task: ITask, targetSid: string) => (payload: WorkerParticipantActionPayload) => boolean;