Installation
Configuration Types
WidgetConfig
The main configuration object for initializing the widget.| Property | Type | Description |
|---|---|---|
token | string | Your organization’s widget token |
language | Language | Widget language (default: 'en') |
bot | { name?, avatarUrl? } | Bot display name and avatar |
isOpen | boolean | Control open state externally |
theme | ThemeOptions | Visual customization |
initialMessages | string[] | Messages shown before first user message |
initialQuestions | string[] | Clickable suggested questions |
collectUserData | boolean | Show welcome screen to collect name/email |
user | UserConfig | Verified or non-verified contact data |
router | object | Routing behavior customization |
oneOpenSessionAllowed | boolean | Limit to one open session |
headers | Record<string, string> | Headers for AI action HTTP requests |
context | Record<string, unknown> | Dynamic context sent with messages |
inline | boolean | Embed widget inline (always open, no trigger) |
ExternalStorage
Custom storage implementation for persisting contact tokens.WidgetComponentType
Type for custom component overrides passed to the provider.ModeComponent
Custom component for conversation modes.ComponentContext
Context passed to all custom components.Contexts
The core package exports context classes that manage widget state. Access these viaWidgetCtx after initialization.
WidgetCtx
The root context that orchestrates all sub-contexts.SessionCtx
Manages chat sessions.| Property | Type | Description |
|---|---|---|
session | SessionDto | null | Currently selected session |
isCreatingSession | boolean | Session creation in progress |
isResolvingSession | boolean | Session resolution in progress |
| Property | Type | Description |
|---|---|---|
data | SessionDto[] | All user sessions |
cursor | string | undefined | Pagination cursor |
isLastPage | boolean | No more pages |
isInitialFetchLoading | boolean | Initial fetch in progress |
MessageCtx
Manages chat messages.| Property | Type | Description |
|---|---|---|
messages | WidgetMessageU[] | All messages |
isSendingMessage | boolean | Message send in progress |
isSendingMessageToAI | boolean | Waiting for AI response |
lastAIResMightSolveUserIssue | boolean | AI thinks issue may be resolved |
isInitialFetchLoading | boolean | Initial fetch in progress |
ContactCtx
Manages contact/user state.| Property | Type | Description |
|---|---|---|
contact | { token: string; externalId?: string } | null | Current contact |
extraCollectedData | Record<string, string> | Extra collected fields |
isCreatingUnverifiedContact | boolean | Contact creation in progress |
RouterCtx
Manages screen navigation.| Screen | Description |
|---|---|
welcome | Collect user data before starting |
sessions | List of previous sessions |
chat | Active chat screen |
CsatCtx
Manages CSAT submissions.PrimitiveState
A simple reactive state container used by all contexts.Message Types
Messages are typed as a union. Use thetype field to discriminate between message kinds.
WidgetUserMessage
Messages sent by the end user.| Field | Type | Description |
|---|---|---|
id | string | Unique message identifier |
type | 'USER' | Discriminator literal |
content | string | Message text content |
deliveredAt | string | null | Delivery timestamp |
attachments | MessageAttachmentType[] | File attachments |
timestamp | string | null | Message timestamp |
user | object | User metadata |
WidgetAiMessage
Messages from the AI assistant.| Field | Type | Description |
|---|---|---|
id | string | Unique message identifier |
type | 'AI' | Discriminator literal |
component | string | Component key ('bot_message' or custom) |
data.message | string | Message text content |
data.variant | 'default' | 'error' | Display variant |
data.action | object | null | Action call result |
agent | Agent | Agent metadata |
attachments | MessageAttachmentType[] | File attachments |
WidgetAgentMessage
Messages from human agents.| Field | Type | Description |
|---|---|---|
id | string | Unique message identifier |
type | 'AGENT' | Discriminator literal |
component | 'agent_message' | Component key |
data.message | string | Message text content |
agent | Agent | Agent metadata (name, avatar) |
attachments | MessageAttachmentType[] | File attachments |
System Messages
System messages represent events like CSAT prompts and state checkpoints.WidgetSystemMessage__CsatRequested
Triggered when a CSAT prompt should be displayed.WidgetSystemMessage__CsatSubmitted
Contains the submitted CSAT rating.| Field | Type | Description |
|---|---|---|
data.payload.score | number | null | Rating score (typically 1-5) |
data.payload.feedback | string | null | Optional text feedback |