Skip to main content

getConfig

getConfig(): ChatBotConfig

Returns the current configuration of the ChatBot widget.

Example of usage

const state = widget.getConfig();
const { activeChat } = state;

Properties

  • activeAgent?: TID - Specifies which agent will respond to user messages.
  • activeChat?: TID - Indicates which chat is currently active (selected).
  • agents?: Agent[] - Contains a list of available agents for the chat.
  • chats?: Chat[] - Contains a list of chats previously created by the current user.
  • focus?: boolean - Controls the auto-focus feature of the chat. Default is true.
  • format?: "text" | "markdown" - Specifies the format for messages, either plain text or markdown.
  • messages?: Message[] - Defines initial messages in the chat.
  • readonly?: boolean - Allows or denies data modifications. Default is false.
  • render?: "blocks" | "cards" | "bubbles" | "flow" - Specifies the template for rendering messages in the chat.
  • sidebar?: boolean - Determines the visibility of the sidebar. Default is true.
  • user?: User - Contains information about the current user.
  • withCache?: boolean - Specifies whether the chat will store user messages locally or rely on the server.

Use-cases

Accessing Active Chat

const state = widget.getConfig();
const { activeChat } = state;

Used to retrieve the currently active chat session identifier. This can be useful for identifying which chat is active when the widget is loaded.

Listing Agents

const state = widget.getConfig();
const { agents } = state;

Retrieves a list of available agents for the chat. This can be used to display agent options to the user or for internal logic that depends on available agents.

Checking Sidebar Visibility

const state = widget.getConfig();
const { sidebar } = state;

Checks the visibility status of the sidebar. This is useful for dynamically adjusting the UI based on whether the sidebar is shown or hidden.

Determining Message Format

const state = widget.getConfig();
const { format } = state;

Determines the format of the messages, whether they are in plain text or markdown. This can be useful for rendering messages correctly in the UI.