import { Media } from "@twilio/conversations"; import { Descendant } from "slate"; import { ChatChannelState } from "../state"; import { ConversationState } from "../state/ConversationState"; /** * @typedef ChatActionPayload * @property {string} [conversationSid] - Unique identifier of the conversation. * @property {ConversationState} [conversation] - Represents a remote conversation. * @memberof Actions */ export interface ChatActionPayload { channelSid?: string; channel?: ChatChannelState.ChannelState; conversationSid?: string; conversation?: ConversationState; } /** * @typedef {Actions.ChatActionPayload} ChatActionInputTextPayload * @property {string} body - Content of the message. * @property {number} [selectionStart] - Represents the selection start position in the message body. * @property {number} [selectionEnd] - Represents the selection end position in the message body. * @memberof Actions */ export interface ChatActionInputTextPayload extends ChatActionPayload { body: string; selectionStart?: number; selectionEnd?: number; htmlValue?: Descendant[]; } /** * @typedef {Actions.ChatActionPayload} ChatActionAttachFilePayload * @property {File} file - Media file to be attached * @deprecated * @deprecatedSince 2.0.0 * @altRecommendation Use `Actions.AttachFiles` instead * @altRecommendationExample * import { Actions } from "@twilio/flex-ui"; * Actions.invokeAction("AttachFiles", { files: [file], conversationSid: "unique_conversation_identifier" }); * @altRecommendationLink https://assets.flex.twilio.com/docs/releases/flex-ui/latest/ui-actions/Actions/#AttachFiles * @memberof Actions */ export interface ChatActionAttachFilePayload extends ChatActionPayload { file: File; } /** * @typedef {Actions.ChatActionPayload} ChatActionAttachFilePayload * @property {File[]} files - Media files to be attached * @memberof Actions */ export interface ChatActionAttachFilesPayload extends ChatActionPayload { files: File[]; } /** * @typedef {Actions.ChatActionPayload} ChatActionDownloadMediaPayload * @property {Media} media - Represents a downloadable media file * @memberof Actions */ export interface ChatActionDownloadMediaPayload extends ChatActionPayload { media: Media; } /** * @typedef {Actions.ChatActionPayload} ChatActionSendMessageTextPayload * @property {string} body - Content of the message. * @property {any} [messageAttributes] - Represents chat message attributes to set. * @property {string} subject - Subject of the message. * @property {File[]} attachedFiles - Media files to be attached (only if new send message behaviour is enabled) * @memberof Actions */ export interface ChatActionSendMessageTextPayload extends ChatActionPayload { body: string; messageAttributes?: any; subject?: string; attachedFiles?: File[]; } export interface ChatActionSendMessageHTMLTextPayload extends ChatActionPayload { body?: string; messageAttributes?: any; subject?: string; attachedFiles?: File[]; htmlBody: string; plainTextBody: string; } /** * @typedef ChatActionContentTemplateVariable * @property {string} name - The name of the content template variable. * @property {string} value - The value of the content template variable. * @since 2.12.0 * @memberof Actions */ export interface ChatActionContentTemplateVariable { name: string; value: string; } /** * @typedef {Actions.ChatActionPayload} ChatActionSendRichContentMessagePayload * @property {string} contentSid - The content template sid to send. * @property {ChatActionContentTemplateVariable[]} [contentVariables] - Optional array of variables defined for the content template. [{ name: "variable_name", value: "variable_value" }] * @property {any} [messageAttributes] - Represents chat message attributes to set. * @since 2.12.0 * @memberof Actions */ export interface ChatActionSendRichContentMessagePayload extends ChatActionPayload { contentSid: string; contentVariables?: ChatActionContentTemplateVariable[]; messageAttributes?: any; } /** * @typedef {Actions.ChatActionPayload} ChatActionSendMediaMessagePayload * @property {File} file - Media file to send. * @property {any} [messageAttributes] - Represents chat message attributes to set. * @memberof Actions */ export interface ChatActionSendMediaMessagePayload extends ChatActionPayload { file: File; messageAttributes?: any; } /** * @typedef {Actions.ChatActionPayload} ChatActionAttachFilePayload * @property {string} accordionId - Id of the accordion to be opened * @property {boolean} [open] - Set true to open the accordion, false to close it, undefined to just toggle it * @memberof Actions */ export interface ChatActionToggleEmailAccordionPayload extends ChatActionPayload { accordionId: string; open?: boolean; } /** * @static * @category Actions * @namespace Actions * @hideconstructor */ export declare class ChatActions { static registerActions(): void; private static sendMessage; private static sendMediaMessage; private static sendRichContentMessage; private static sendTyping; private static setInputText; private static attachFile; private static attachFiles; private static detachFile; private static downloadMedia; private static toggleEmailAccordion; private static cancelEmailDraftDebounce; private static dispatchInputTextAction; private static updateChatActionPayload; private static validateDownloadingFile; private static validateSendingFiles; private static validateAttachingFiles; }