import { IContactAddress } from "../../Contacts/contacts"; import { UserInfo } from "../../Users/UserTrii"; import { IChannelInfo } from "../Channels/Channel"; export interface CommentData { userId: string; text: string; timestamp: Date; } export interface MessageContactData { address?: string; name?: string; imageUrl?: string; isGroup?: boolean; groupName?: string; groupAddress?: string; whatsappUserId?: string; whatsappParentUserId?: string; } export declare enum MessageDirection { IN = 1, OUT = 2 } export declare enum MessageVisibility { PUBLIC = "PUBLIC", INTERNAL = "INTERNAL" } export declare enum MessageAck { ACK_SCHEDULED = -3, ACK_QUEUE = -2, ACK_PENDING = -1, ACK_NONE = 0, ACK_ERROR = 1, ACK_SERVER = 2, ACK_DEVICE = 3, ACK_READ = 4, ACK_PLAYED = 5 } export interface ackLog { ack: MessageAck; timestamp: Date; errorMessage: string; userId?: string; } export declare enum MessageType { CHAT = 1, CHAT_EXTERNAL = 2, NOTE = 3, CDR_PBX = 4, CALL = 5, COMMENT = 6, INFO = 7, NOTIFICATION_NEW_CONVERSATION = 12, N2B = 13 } export type MessageType2 = 'audio' | 'button' | 'contact' | 'document' | 'image' | 'location' | 'sticker' | 'text' | 'video' | 'interactive'; export interface MessageHeader { type: MessageHeaderType; text: string; url: string; mimeType: string; filename: string; locationName: string; locationAddress: string; } export declare enum MessageHeaderType { TEXT = 0, IMAGE = 1, VIDEO = 2, FILE = 3, LOCATION = 4 } export interface MessageText { previewUrl: boolean; body: string; } export interface MessageNote { body: string; } export interface MessageAudio { /** para uso en front */ id: string | ''; /** para uso en front */ filename: string | ''; /**The mime type for the video audio. */ mimeType: string; /**The url of the audio. */ url: string; mediaid?: string; transcript?: string; } export interface MessageImage { /** para uso en front */ id: string | ''; /** para uso en front */ filename: string | ''; /**image/webp */ mimeType: string; /**The url of the image. */ url: string; caption: string; mediaid?: string; } export interface MessageVideo { id: string; animated?: boolean; /**The name for the file on the sender's device. */ filename: string | ''; /**image/webp */ mimeType: string; /**The url of the video. */ url: string; caption: string; mediaid?: string; } export interface MessageCdr { callerId: string; trunk: string; ringTime: number; connectedTime: number; totalTime: number; calls: MessageCdrCall[]; } export interface MessageCdrCall { extension: string; ringTime: number; connectedTime: number; status: MessageCdrCallStatus; audioUrl: string; } export declare enum MessageCdrCallStatus { ANSWERED = 1, UNANSWERED = 2, LOST = 3 } export interface MessageLocation { lat: string; lng: string; title: string; description: string; url: string; } export interface MessageDocument { id: string; /**The name for the file*/ filename: string | ''; /** mimetype o the file */ mimeType: string; caption: string; /**The url of the fie. */ url: string; mediaid?: string; } export interface MessageReference { channelId: string; externalId?: string; messageId?: string; messageData?: MessageReferenceData; } export interface MessageReferenceData { messageType: MessageType2; isStatus: boolean; isReel: boolean; isStory: boolean; body?: string; mimeType?: string; url?: string; filename?: string; caption?: string; } export interface MessageReaction { emoji: string; emojiName: string; users: MessageReactionUser[]; } export interface MessageReactionUser { timestamp: Date; fromMe: boolean; userId: string; address: string; name: string; imageUrl: string; } export interface MessageEmail { /**Cuenta de correo electrónico asociado a Trii */ emailAccount: string; /**Remitente del correo */ from: string; /**Lista de destinatarios (puede ser uno o varios) */ to: IContactAddress[]; /**Lista de destinatarios en copia (opcional) */ cc?: IContactAddress[]; /**Lista de destinatarios en copia oculta (opcional) */ bcc?: IContactAddress[]; /**Asunto del correo */ subject: string; preHeader: string; /**Cuerpo del correo */ bodyHtml: string; bodyText: string; /**Lista de archivos adjuntos (opcional) */ attachments?: EmailDocument[]; /**Marca de tiempo del correo */ timestamp: Date; /**Encabezados del correo (p. ej., {"Reply-To": "reply@example.com"}) */ headers?: Record; /**Indicador de si el correo se considera spam (opcional) */ isSpam?: boolean; /**Puntuación de spam (opcional) */ spamScore?: number; bodyJson?: string; projectData?: string; } export interface EmailDocument { id: string; /**The name for the file*/ filename: string | ''; /** mimetype o the file */ mimeType: string; /**The url of the fie. */ url: string; isInline: boolean; } export interface MessageSticker { /**The ID for the video. */ id: string; /**The caption for the video, if provided. */ caption: string | ''; /**The name for the file on the sender's device. */ filename: string | ''; /**The mime type for the video file. */ mimeType: string; /**The url of the video. */ url: string; animated: boolean; mediaid?: string; } export interface MessageInfo { code: string; data: MessageInfoVar; } export interface MessageInfoVar { id?: string; contactId?: string; contactName?: string; userId?: string; userName?: string; transferTo?: string; transferToName?: string; reassignedTo?: string; reassignedToName?: string; groupName?: string; conversationDetails?: string; } export interface MessageTicket { ticketId: string; ticketNumber?: number; ticketTitle?: string; } export interface MessageForm { url: string; title?: string; subTitle?: string; color?: string; status: MessageFormStatus; responses?: MessageFormResponse[]; expireAt?: Date; completedAt?: Date; } export interface MessageButton { text: string; url: string; payload: string; type: MessageButtonType; } export declare enum MessageButtonType { TEXT = 0, URL = 1 } export interface MessageFormResponse { question: string; response: string; } export declare enum MessageFormStatus { pending = 0, completed = 1, expired = 2 } export interface MessagePoll { pollName: string; pollOptions: MessagePollOption[]; pollSelectableOptionsCount: number; pollInvalidated: boolean; } export interface MessagePollOption { name: string; localId: string; } export interface MessageContact { name: MessageContactName; profileUrl?: string; birthday?: string; org?: MessageContactOrg; phones?: MessageContactPhone[]; emails?: MessageContactEmail[]; addresses?: MessageContactAddress[]; } export interface MessageContactAddress { street: string; city: string; state: string; zip: string; country: string; countryCode: string; type: string; urls: []; } export interface MessageContactEmail { email: string; type: string; } export interface MessageContactName { formattedName: string; firstName?: string; lastName?: string; middleName?: string; } export interface MessageContactOrg { company: string; department: string; title: string; } export interface MessageContactPhone { phone: string; type: string; } export interface MessageContactUrl { url: string; type: string; } export interface MessageTemplateVar { var?: string; value: string; btn?: number; } export interface IMessage { id: string; externalId?: string; shardKey?: string; campaignId?: string; /**only for Front-End */ idLocal?: number; spaceId: string; conversationId: string; workflowId?: string; /**only for Front-End */ contactId?: string; read?: boolean; /**ISO8601 timestamp */ timestamp: Date; scheduledDate?: Date | null; userId: string; channelInfo?: IChannelInfo; /** * ejemplos * wa:5493584023801, * email:info@trii.app, * Fb:11111111111111111, * Ig:22222222222222222, * sms:3584023801 * */ from: string; to: string; remoteContactData?: MessageContactData; direction: MessageDirection; /** Authorization must use visibility instead of inferring it from MessageType. */ visibility: MessageVisibility; ack: MessageAck; ackLogs: ackLog[]; forwarded: boolean; remoteDeleted: boolean; type: MessageType; header?: MessageHeader; footer?: string; mentions: []; templateId?: string; templateName?: string; templateMediaUrl?: string; templateHeaderVars?: MessageTemplateVar[]; templateBodyVars?: MessageTemplateVar[]; templateButtonVars?: MessageTemplateVar[]; templateLocationName?: string; templateLocationAddress?: string; templateLocationLatitude?: string; templateLocationLongitude?: string; context?: string; text?: MessageText; contacts?: MessageContact[]; audio: MessageAudio; images?: MessageImage[]; videos?: MessageVideo[]; cdr?: MessageCdr; locations?: MessageLocation[]; documents?: MessageDocument[]; stickers?: MessageSticker[]; info?: MessageInfo; form?: MessageForm; ticket?: MessageTicket; email?: MessageEmail; buttons?: MessageButton[]; poll?: MessagePoll; note?: MessageNote; reactions?: MessageReaction[]; messageReference?: MessageReference; comment?: CommentData; isLoaded: boolean; isHighlighted: boolean; edited: boolean; editedAt?: Date; deleted: boolean; deletedAt?: Date; updatedAt?: Date; updatedBy?: UserInfo; }