KiliConfig
The config object passed to KiliChat, or to configureKili(). Shown in each language's syntax:
export type KiliConfig = {
apiBaseUrl: string;
socketBaseUrl?: string;
apiKey: string;
apiSecret: string;
};| Option | Type | Required | Description |
|---|---|---|---|
| apiBaseUrl | string | required | Base URL of the Kili REST API. |
| socketBaseUrl | string | optional | Base URL of the realtime server. Defaults to apiBaseUrl. |
| apiKey | string | required | Your organisation's API key. |
| apiSecret | string | required | Your organisation's API secret. |
Example value: apiBaseUrl is https://api.kili.africa.
Chat, Message and Customer
These are the data types the widget uses. The tables come from the React SDK's types.ts. The Flutter types have the same field names, with some nullability differences listed below.
Chat
| Option | Type | Required | Description |
|---|---|---|---|
| id | number | required | Chat ID. |
| createdAt | Date | required | When the chat was created. |
| updatedAt | string | required | When the chat was last updated. |
| assignedStaffEmail | string | optional | Email of the assigned staff member. |
| assignedStaffFullName | string | optional | Full name of the assigned staff member. |
| assignedStaffId | number | optional | ID of the assigned staff member. |
| assignmentStatus | string | required | Assignment state of the chat. |
| closedAt | Date | optional | When the chat was closed. |
| customerEmail | string | optional | The customer's email. |
| customerFullName | string | optional | The customer's full name. |
| customerId | number | optional | The customer's ID. |
| initiationChannel | string | optional | Channel the chat started on, such as web_widget. |
| lastMessageSentAt | string | optional | When the last message was sent. |
| lastMessagePreview | string | optional | Preview text of the last message. |
| lastMessageSenderAccountType | 'customer' | 'staff' | optional | Who sent the last message. |
| priority | string | required | Priority of the chat. |
| snoozedAt | string | optional | When the chat was snoozed. |
| snoozedByStaffEmail | string | optional | Email of the staff member who snoozed the chat. |
| snoozedUntil | string | optional | When a snoozed chat wakes up. |
| staffMemberEmailsMentioned | string | optional | Staff emails mentioned in the chat. |
| status | string | required | Status of the chat. |
| summary | string | optional | Summary of the chat. |
| tags | string | required | Tags on the chat. |
| title | string | optional | Title of the chat. |
Message
| Option | Type | Required | Description |
|---|---|---|---|
| id | number | required | Message ID. |
| createdAt | Date | required | When the message was created. |
| updatedAt | Date | required | When the message was last updated. |
| attachmentPath | string | optional | Storage path of an attachment. |
| attachmentType | string | optional | MIME type of an attachment. |
| attachmentUrl | string | optional | URL of an attachment. |
| deliveredAt | Date | optional | When the message was delivered. |
| chatId | number | optional | ID of the chat the message belongs to. |
| content | string | optional | Text of the message. |
| extraData | string | optional | Extra data attached to the message. |
| openedByReceiverAt | Date | optional | When the receiver opened the message. |
| orgId | number | optional | ID of the organisation. |
| senderEmail | string | optional | Email of the sender. |
| senderId | number | optional | ID of the sender. |
| sentAt | string | optional | When the message was sent. |
| senderAccountType | string | optional | Account type of the sender, such as CUSTOMER. |
| senderFirstName | string | optional | First name of the sender. |
| senderLastName | string | optional | Last name of the sender. |
| mentionedStaffEmails | string | optional | Staff emails mentioned in the message. |
| type | string | required | Message type, such as TEXT. |
Customer
| Option | Type | Required | Description |
|---|---|---|---|
| id | number | required | Customer ID. |
| createdAt | Date | required | When the customer was created. |
| updatedAt | Date | required | When the customer was last updated. |
| city | string | optional | City. |
| country | string | optional | Country. |
| device | string | optional | Device name. |
| string | optional | Email address. | |
| firstName | string | optional | First name. |
| identifier | string | optional | External identifier. |
| lastName | string | optional | Last name. |
| middleName | string | optional | Middle name. |
| orgId | number | optional | ID of the organisation. |
| phoneCountryCode | string | optional | Country code of the phone number. |
| phoneNumberSuffix | string | optional | Phone number without the country code. |
| state | string | optional | State or region. |
| username | string | optional | Username. |
Dart differences
- Field names match in both SDKs. In Dart,
Chat.createdAt, thecreatedAtandupdatedAtfields ofMessageandCustomer, andCustomer.idare nullable (DateTime?,int?). Some fields that are required in TypeScript are nullable in Dart. Message.idisObject?in Dart. It keeps the raw value from the API and compares ids as strings, so either a number or a string works.
ChatAction
The typing and upload states sent with a chat_action event. The widget uses the typing values.
type ChatAction =
| 'typing.started'
| 'typing.stopped'
| 'uploading_file.started'
| 'uploading_file.stopped';SocketEvent
Every constant is the same in the React, Vue and Flutter SDKs. The last column shows how the widget uses each one. Events marked as used by the Kili agent app are sent or handled on the agent side, and the widget doesn't use them.
| Constant | Wire value | Role |
|---|---|---|
| SocketEvent.Connection | connection | Not used. The widget listens for the literal 'connect'. |
| SocketEvent.Disconnect | disconnect | Widget logs it. |
| SocketEvent.Error | error | Widget logs it. |
| SocketEvent.AssignChat | assign_chat | Kili agent app |
| SocketEvent.ChatAction | chat_action | Widget listens and emits (typing indicators) |
| SocketEvent.ChatAssigned | chat_assigned | Kili agent app |
| SocketEvent.ChatDeassigned | chat_deassigned | Kili agent app |
| SocketEvent.ChatStarted | chat_started | Widget listens (a new chat was started) |
| SocketEvent.ChatUpdated | chat_updated | Widget listens (updates the open chat) |
| SocketEvent.ChatWindowClosed | chat_window_closed | Kili agent app |
| SocketEvent.ChatWindowOpened | chat_window_opened | Kili agent app |
| SocketEvent.CloseChat | close_chat | Kili agent app |
| SocketEvent.InternalNote | internal_note | Kili agent app |
| SocketEvent.JoinAllUnclosedChatRooms | join_all_unclosed_chat_rooms | Widget emits on connect |
| SocketEvent.JoinChatRoom | join_chat_room | Widget emits after a chat starts |
| SocketEvent.JoinedChatRoom | joined_chat_room | Logged by SocketProvider (advanced) |
| SocketEvent.LeaveRoom | leave_room | Kili agent app |
| SocketEvent.MarkMsgAsRead | mark_msg_as_read | Kili agent app |
| SocketEvent.Message | message | Widget emits to send a message |
| SocketEvent.MessageDelivered | message_delivered | Widget listens (adds a message to the thread) |
| SocketEvent.NewMention | new_mention | Kili agent app |
| SocketEvent.PrioritizeChat | prioritize_chat | Kili agent app |
| SocketEvent.RefetchChats | refetch_chats | Kili agent app |
| SocketEvent.ReopenChat | reopen_chat | Kili agent app |
| SocketEvent.RefetchChatCounts | refetch_chat_counts | Kili agent app |
| SocketEvent.SnoozeChat | snooze_chat | Kili agent app |
| SocketEvent.StartChat | start_chat | Widget emits when the visitor starts a conversation |
Connection events
The widget listens for the literal connect event, not SocketEvent.Connection. It also emits message to send a visitor's message.
Storage keys
The SDK keeps the visitor's session in browser storage. In Flutter, localStorage is backed by shared_preferences, and each key gets a kili. prefix so it can't clash with your app's own keys. sessionStorage is kept in memory for the app's lifetime.
| Constant | Web key | Flutter key | Holds |
|---|---|---|---|
| LocalStorageKeys.User | localStorage: u | kili.u | The customer object (JSON). |
| LocalStorageKeys.JwtAccessToken | localStorage: at | kili.at | The access token sent as a Bearer token. |
| LocalStorageKeys.AccessTokenExp | localStorage: atexp | kili.atexp | When the access token expires, from the registration response. |
| LocalStorageKeys.JwtRefreshToken | localStorage: rt | kili.rt | A refresh token. The state API can store it, but KiliChat doesn't set it. |
| SessionStorageKeys.ActiveChat | sessionStorage: ac | ac (in memory) | The chat the visitor has open. |
Clearing storage
Clearing the stored customer (u) starts a fresh customer on the next load. Clearing only the access token (at) doesn't create a new customer. The next load registers the stored customer again and gets a new token.