Skip to main content

Data Models

TypeScript interfaces for the core data types used across the Lovina Chat SDK.

Message

Represents a single chat message.

interface Message {
id: string;
content: string;
messageType: MessageType;
contentType: 'text' | 'input_select' | 'cards' | 'form';
status: MessageStatus;
conversationId: string;
sender?: MessageSender;
replyTo?: string;
createdAt: string; // ISO 8601 timestamp
attachments?: Attachment[];
contentAttributes?: Record<string, unknown>;
}

type MessageType = 'incoming' | 'outgoing' | 'activity';
type MessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
FieldTypeDescription
idstringServer-generated unique ID
contentstringMessage text (may be empty for file-only messages)
messageTypeMessageType"incoming" = from agent, "outgoing" = from user, "activity" = system
contentTypestringContent format: "text", "input_select", "cards", or "form"
statusMessageStatusDelivery status
conversationIdstringID of the parent conversation
senderMessageSenderPresent for incoming messages
replyTostringParent message ID (for threaded replies)
createdAtstringISO 8601 timestamp
attachmentsAttachment[]File attachments
contentAttributesRecord<string, unknown>Extra structured data

MessageSender

Represents the sender of a message.

interface MessageSender {
id: string;
name: string;
avatarUrl?: string;
type: 'agent' | 'user' | 'bot';
}
FieldTypeDescription
idstringUnique sender ID
namestringDisplay name
avatarUrlstringProfile image URL
typestringSender type: "agent", "user", or "bot"

Attachment

Represents a file attached to a message.

interface Attachment {
id: string;
fileType: 'image' | 'audio' | 'video' | 'file';
dataUrl: string;
thumbUrl?: string;
fileSize?: number;
fileName?: string;
contentType?: string;
}
FieldTypeDescription
idstringUnique attachment ID
fileTypestringResolved type: "image", "audio", "video", or "file"
dataUrlstringFull URL to download or view the file
thumbUrlstringThumbnail URL (images only)
fileSizenumberSize in bytes
fileNamestringOriginal file name
contentTypestringMIME type (e.g., "image/png")

fileType resolution from MIME type:

MIME prefixfileType
image/*"image"
audio/*"audio"
video/*"video"
Everything else"file"

Conversation

Represents a chat conversation.

interface Conversation {
id: string;
inboxId: string;
status: ConversationStatus;
messages: Message[];
contact?: Contact;
meta?: ConversationMeta;
}

interface ConversationMeta {
userLastSeenAt?: number; // Unix timestamp (seconds)
agentLastSeenAt?: number;
assignee?: MessageSender;
}

type ConversationStatus = 'open' | 'resolved' | 'pending';
FieldTypeDescription
idstringUnique conversation ID
inboxIdstringID of the inbox this conversation belongs to
statusConversationStatusCurrent status: "open", "resolved", or "pending"
messagesMessage[]List of messages in the conversation
contactContactThe customer contact
metaConversationMetaMetadata including last-seen timestamps and assignee

Contact

Represents a customer contact.

interface Contact {
id: string;
name: string;
email?: string;
avatarUrl?: string;
pubsubToken?: string;
}
FieldTypeDescription
idstringUnique contact ID
namestringDisplay name
emailstringEmail address
avatarUrlstringProfile image URL
pubsubTokenstringToken for WebSocket subscription

Agent

Represents a support agent.

interface Agent {
id: string;
name: string;
avatarUrl?: string;
availability: 'online' | 'offline' | 'busy';
}
FieldTypeDescription
idstringUnique agent ID
namestringDisplay name
avatarUrlstringProfile image URL
availabilitystringCurrent status: "online", "offline", or "busy"

UserData

Represents user identification data sent from the SDK to the backend.

interface UserData {
identifier?: string;
identifierHash?: string;
name?: string;
email?: string;
avatarUrl?: string;
phoneNumber?: string;
companyName?: string;
customAttributes?: Record<string, unknown>;
}

Enums and Type Aliases

type MessageType = 'incoming' | 'outgoing' | 'activity';
type MessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed';
type ConversationStatus = 'open' | 'resolved' | 'pending';
type DisplayMode = 'popup' | 'sidebar' | 'fullscreen';
type ColorScheme = 'light' | 'dark' | 'auto';
type Position = 'left' | 'right';
type BubbleType = 'standard' | 'expanded';
type TransportType = 'websocket' | 'sse' | 'longpolling';
type TransportState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting';