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';
| Field | Type | Description |
|---|---|---|
id | string | Server-generated unique ID |
content | string | Message text (may be empty for file-only messages) |
messageType | MessageType | "incoming" = from agent, "outgoing" = from user, "activity" = system |
contentType | string | Content format: "text", "input_select", "cards", or "form" |
status | MessageStatus | Delivery status |
conversationId | string | ID of the parent conversation |
sender | MessageSender | Present for incoming messages |
replyTo | string | Parent message ID (for threaded replies) |
createdAt | string | ISO 8601 timestamp |
attachments | Attachment[] | File attachments |
contentAttributes | Record<string, unknown> | Extra structured data |
MessageSender
Represents the sender of a message.
interface MessageSender {
id: string;
name: string;
avatarUrl?: string;
type: 'agent' | 'user' | 'bot';
}
| Field | Type | Description |
|---|---|---|
id | string | Unique sender ID |
name | string | Display name |
avatarUrl | string | Profile image URL |
type | string | Sender 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;
}
| Field | Type | Description |
|---|---|---|
id | string | Unique attachment ID |
fileType | string | Resolved type: "image", "audio", "video", or "file" |
dataUrl | string | Full URL to download or view the file |
thumbUrl | string | Thumbnail URL (images only) |
fileSize | number | Size in bytes |
fileName | string | Original file name |
contentType | string | MIME type (e.g., "image/png") |
fileType resolution from MIME type:
| MIME prefix | fileType |
|---|---|
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';
| Field | Type | Description |
|---|---|---|
id | string | Unique conversation ID |
inboxId | string | ID of the inbox this conversation belongs to |
status | ConversationStatus | Current status: "open", "resolved", or "pending" |
messages | Message[] | List of messages in the conversation |
contact | Contact | The customer contact |
meta | ConversationMeta | Metadata including last-seen timestamps and assignee |
Contact
Represents a customer contact.
interface Contact {
id: string;
name: string;
email?: string;
avatarUrl?: string;
pubsubToken?: string;
}
| Field | Type | Description |
|---|---|---|
id | string | Unique contact ID |
name | string | Display name |
email | string | Email address |
avatarUrl | string | Profile image URL |
pubsubToken | string | Token for WebSocket subscription |
Agent
Represents a support agent.
interface Agent {
id: string;
name: string;
avatarUrl?: string;
availability: 'online' | 'offline' | 'busy';
}
| Field | Type | Description |
|---|---|---|
id | string | Unique agent ID |
name | string | Display name |
avatarUrl | string | Profile image URL |
availability | string | Current 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';