import { ITask } from "./models"; /** * @enum {"AddToConversation" | "DeactivateConversation" | "LeaveConversation"} ChatOrchestration * @property {"AddToConversation"} AddToConversation Adds worker to a conversation * @property {"DeactivateConversation"} DeactivateConversation Deactivates a conversation * @property {"LeaveConversation"} LeaveConversation Leave a conversation * @memberof ChatOrchestrator */ export declare enum ChatOrchestration { AddToConversation = "AddToConversation", DeactivateConversation = "DeactivateConversation", LeaveConversation = "LeaveConversation" } /** * Callback that returns an array of orchestrations based on a task * * @callback ChatOrchestrator~ChatOrchestrationsCallback * @param {ITask} task task * @returns {Array} * @example * import { ChatOrchestratorEvent } from "@twilio/flex-ui"; * const chatOrchestrationsCallback = (task) => { * if (task.sid === "WT12345") { * return [ChatOrchestratorEvent.AddToConversation]; * } * return [ChatOrchestratorEvent.LeaveConversation]; * }; */ export type ChatOrchestrationsCallback = (task: ITask) => Array; /** * @typedef ChatOrchestrationsEvents * @property {Set | ChatOrchestrator.ChatOrchestrationsCallback} accepted orchestrations for reservation accepted events * @property {Set | ChatOrchestrator.ChatOrchestrationsCallback} wrapup orchestrations for reservation wrapup events * @property {Set | ChatOrchestrator.ChatOrchestrationsCallback} completed orchestrations for reservation completed events * @memberof ChatOrchestrator */ export interface ChatOrchestrationsEvents { accepted: Set | ChatOrchestrationsCallback; wrapup: Set | ChatOrchestrationsCallback; completed: Set | ChatOrchestrationsCallback; [k: string]: Set | ChatOrchestrationsCallback; } /** * Chat orchestration manager. Use to disable Flex UI chat orchestrations. * * @class ChatOrchestrator * @hideconstructor * @category Framework */ export declare class ChatOrchestrationManager { private readonly events; private readonly mapEventToFunc; /** * Get orchestrations or orchestrations callback for a reservation event * * @method getOrchestrations * @param {"accepted" | "wrapup" | "completed"} event to get orchestrations for * @returns {Array | ChatOrchestrator.ChatOrchestrationsCallback} Either an Array of orchestrations or orchestrations callback * @memberof ChatOrchestrator * @example * import { ChatOrchestrator } from "@twilio/flex-ui"; * ChatOrchestrator.getOrchestrations("accepted"); */ getOrchestrations(event: keyof ChatOrchestrationsEvents): Array | ChatOrchestrationsCallback; /** * Set orchestrations for a reservation event * * @method setOrchestrations * @param {"accepted" | "wrapup" | "completed"} event to get orchestrations for * @param {Array | ChatOrchestrator.ChatOrchestrationsCallback } orchestrations to set for * @memberof ChatOrchestrator * @example * import { ChatOrchestrator } from "@twilio/flex-ui"; * const orchestrationsCallback = (task) => { * if (task.sid === "WT12345") { * return []; * } * }; * ChatOrchestrator.setOrchestrations("accepted", orchestrationsCallback); */ setOrchestrations(event: keyof ChatOrchestrationsEvents, orchestrations: Array | ChatOrchestrationsCallback): void; /** * Clears / disables all orchestrations for chat * * @method clearAllOrchestrations * @memberof ChatOrchestrator * @example * import { ChatOrchestrator } from "@twilio/flex-ui"; * ChatOrchestrator.clearAllOrchestrations(); */ clearAllOrchestrations(): void; /** * Orchestrates Task wrapup action * * @method orchestrateWrapupTask * @param {ITask} task task to orchestrate * @returns {Promise} promise with boolean indicating if orchestration happened * @memberof ChatOrchestrator * @example * import { ChatOrchestrator } from "@twilio/flex-ui"; * ChatOrchestrator.orchestrateWrapupTask(taskObject); */ orchestrateWrapupTask(task: ITask): Promise; /** * Orchestrates Task complete action * * @method orchestrateCompleteTask * @param {ITask} task task to orchestrate * @returns {Promise} promise with boolean indicating if orchestration happened * @memberof ChatOrchestrator * @example * import { ChatOrchestrator } from "@twilio/flex-ui"; * ChatOrchestrator.orchestrateCompleteTask(taskObject); */ orchestrateCompleteTask(task: ITask): Promise; /** * @private */ handleReservationEvent(event: keyof ChatOrchestrationsEvents, task: ITask): Promise; private addWorkerToConversationInternal; private deactivateConversationInternal; private leaveAgentFromChatInternal; private isChatOrchestrationsCallbackType; private getOrchestrationsSet; private validateOrchestrations; } /** * Singleton instance of ChatOrchestrator * @type {ChatOrchestrator} * @category Framework * @private */ export declare const ChatOrchestrator: ChatOrchestrationManager;