Message
type MessageTypes = 'TEXT' | 'IMAGE' | 'AUDIO' | 'FILE' | 'DOCUMENT' | 'LOCATION' | 'POSTBACK';
type By = 'user' | 'bot' | 'operator' | 'company' | 'client';
type MessageStatuses = 'CREATED' | 'DELIVERED' | 'FAILED' | 'DELIVERED_CHANNEL' | 'DELIVERED_USER';
type Option = {
type: string;
title: string;
payload: Record<string, any>;
order: number;
url?: string;
}
interface BaseMessage {
by: By;
roomId: string;
senderId: string;
createdAt: string;
timestamp: number;
options?: Option[];
type: MessageTypes;
id: string | number;
status: MessageStatuses;
}
interface TextMessage extends BaseMessage {
text: string;
readonly type: 'TEXT';
}
interface PostbackMessage extends BaseMessage {
text: string;
payload: Record<string, any>;
readonly type: 'POSTBACK';
}
interface ImageMessage extends BaseMessage {
mediaUrl: string;
caption?: string;
height: number;
width: number;
readonly type: 'IMAGE';
}
interface AudioMessage extends BaseMessage {
mediaUrl: string;
duration?: number;
readonly type: 'AUDIO';
}
interface DocumentMessage extends BaseMessage {
mediaUrl: string;
caption?: string;
readonly type: 'DOCUMENT' | 'FILE';
}
interface LocationMessage extends BaseMessage {
coordinates: {
lat: string;
lng: string;
};
readonly type: 'LOCATION';
}
type Message = TextMessage | ImageMessage | AudioMessage | DocumentMessage | LocationMessage | PostbackMessage
Last updated