Skip to main content

overview

To initialize the ChatBot widget, create an instance using the following code snippet:

const chat = new ChatBot(html_container, config);

This parameter specifies the container where the ChatBot widget will be rendered. It accepts the following types:

  • HTMLElement: Directly pass an HTML element which will act as the container for the widget.
  • CSS Locator String: Use a CSS selector string to specify the container. Only the first match will be used as the widget container.
    • #some - Selects an element by its ID.
    • .some - Selects an element by its class name.

This optional parameter is a configuration object that allows customizing the widget's behavior.

interface ChatBotConfig {
activeAgent?: TID; // Define which agent will respond to the user's messages
activeChat?: TID; // Define which chat is active (selected)
agents?: Agent[]; // Provide list of agents for the chat
chats?: Chat[]; // Provide list of chats previously created by current user
focus?: boolean; // Control auto-focus ability of chat, set as true by default
format?: "text" | "markdown"; // Use plain text or markdown format for messages
messages?: Message[]; // Define initial messages in the chat
readonly?: boolean; // Allow or deny data changes, set as false by default
render?: "blocks" | "cards" | "bubbles" | "flow"; // Render messages in chat with specified template
sidebar?: boolean; // Define will sidebar will be visible or hidden, set as true by default
user?: User; // Define information about current user
withCache?: boolean; // Define will chat store user's messages locally or depend on server side
}

ChatBot API overview

Methods

addChatinitializes a new chat within the ChatBot widget
addMessageadds a new message to the chat UI
appendMessageappends additional text to an existing message in the chat interface
deleteChatremoves a chat session identified by its unique ID
getConfigdynamically updates the ChatBot widget configuration
interceptallows interception of specific widget events
onregisters event listeners for chat-related events
provideMessagesprovides updated messages to the chat widget
requestMessagesrequests the messages for a specific chat identified by its unique ID
selectChatselects a specific chat session by its unique identifier and optionally specifies the agent
setConfigreturns current configuration of the ChatBot widget
typeMessagechanges the typing state for a given message

Properties

activeAgentagent response control
activeChatactive chat control
agentsconfiguration and management of chat agents
chatslist of chats previously created by the current user
focusauto-focus functionality
formatmessage display format control
messages
readonlychatbot widget's data modification control
rendervisual template configuration
sidebarvisibility control
userinformation about the current user
withCachemessage storage configuration

Actions

add_chatnew chat creation
add_messagenew message detection and interception
append_messageevent to detect text addition to existing message
delete_chatchat deletion event detection
provide_messagesmessage provisioning
request_messagesmessage retrieval action
select_chatnew chat selection detection
type_messagemessage typing state change