List of instance methods
The following tables list all supported instance methods, grouped by category.Message
Message methods allow you to manage and interact with the chat’s message flow in real time. These methods provide functionality for sending messages, navigating through the message list, and updating message history.| Method name | Description |
|---|---|
send | Sends the specified message to the agent. |
doAutoScroll | Scrolls to the most recent message in the list. |
scrollToMessage | Scrolls the messages list to a specific message. |
updateMessageStateUserDefined | Updates a user_defined property in message state for persistence across thread reloads. |
loadThreadById | Loads an existing conversation thread by its ID. |
restartConversation | Restarts the conversation with the agent. |
User interface
User interface methods allow you to control and customize the visual and interactive aspects of the chat component at runtime. These methods help adapt the chat experience to different contexts and user preferences.| Method name | Description |
|---|---|
changeView | Changes the current view state of the chat widget. |
updateCustomHeaderItems | Updates the display of custom menu items that appear in the chat header. |
getCustomHeaderItems | Retrieves the current set of custom header items that are configured in the chat widget. |
updateLocale | Updates the display language of the chat. |
Chat widget state
Chat widget state methods allow you to retrieve and modify the overall state and configuration of the chat widget.| Method name | Description |
|---|---|
getLocale | Returns the current locale that the chat widget uses. |
Security and identity
Security and identity methods help maintain secure communication and manage the lifecycle of the chat instance. These methods ensure that user authentication and session integrity are preserved during runtime.| Method name | Description |
|---|---|
updateAuthToken | Replaces the current JWT with a new one for continued secure communication. |
destroy | Destroys the web chat and removes it from the page. |
Events
Event methods allow you to subscribe to, manage, and remove event listeners for the chat instance. These methods enable developers to respond to user actions or system events dynamically.Details of instance methods
The following sections detail the supported instance methods.send()doAutoScroll()scrollToMessage()updateMessageStateUserDefined()loadThreadById()restartConversation()changeView()updateCustomHeaderItems()getCustomHeaderItems()updateLocale()getLocale()updateAuthToken()destroy()on()once()off()
send()
Sends a message to the agent. Supports both visible messages and silent messages that are hidden from the chat UI. Syntax| Parameter | Type | Required | Description | |
|---|---|---|---|---|
| message | string | object | Yes | The message to send. Can be a simple string or a MessageRequest object. |
| options | object | No | Optional settings. Use { silent: true } to hide the message from the UI. |
Promise<void> - Resolves when the message is sent.
Example
silent option
Silent messages are sent to the agent but remain hidden from the chat UI. Use the silent option when you need to trigger agent responses without cluttering the conversation.
When you send a silent message, the following sequence occurs:
- Message is sent to the agent for processing.
- Message is hidden from the chat UI.
- Agent can respond (response is visible to user).
- User only sees the agent’s response, not the trigger.
MessageRequest with additional_properties
For more control, use a MessageRequest object to specify message properties including visibility, thread targeting, and custom context.
MessageRequest structure
MessageRequest:
MessageRequest object and the { silent: true } option, the { silent: true } option takes precedence:
-
{ silent: true }option It always hides the message. -
skip_render: truein message
It hides the message. -
skip_render: falsein message It shows the message. - No option or property It shows the message. This is the default.
- Use
{ silent: true }for simple cases and quick overrides. - Use
additional_properties.display_properties.skip_renderwhen buildingMessageRequestobjects. - Combine both when you need to override message object settings at runtime.
doAutoScroll()
Automatically scrolls the chat view to the latest message in the conversation. Syntaxvoid
Example
scrollToMessage()
Scrolls the chat view to a specific message by its ID. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| messageId | string | Yes | The unique identifier of the message to scroll to. |
void
Example
updateMessageStateUserDefined()
Updates theuser_defined field inside a specific message’s state. This provides a mechanism to store custom state on a message that will be reloaded if a thread is reloaded from history. The new data merges with existing data.
When a thread loads, this data can be found on the message at message.message_state.content[<contentId>].user_defined.
Syntax
| Parameter | Type | Required | Description |
|---|---|---|---|
| messageId | string | Yes | The ID of the message to update. |
| contentId | string | Yes | The ID of the message content that must store the user_defined data. |
| data | unknown | Yes | The user-defined value to merge into the message state. |
void
Example
loadThreadById()
Loads an existing conversation thread by its ID, allowing users to resume a previous conversation. This method enables applications to restore chat history and continue from where the user previously left off. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| threadId | string | No | The ID of the conversation thread to load. If not provided, a new thread is created when the user sends a message. |
void
Behavior
- With
threadId: The chat loads the conversation history associated with the specified thread ID. - Without
threadId: A new conversation thread is created when the user sends their first message. - Invalid
threadId: If an invalid or deleted thread ID is provided, a console error is logged. The chat continues to function normally, allowing the user to proceed with the current conversation.
send or pre:send events, for example:
restartConversation()
Restarts the current chat conversation, resetting all related state and starting a new conversation thread. SyntaxPromise<void> - A promise that resolves when the conversation has been restarted.
Example
changeView()
Updates the chat UI view by showing or hiding the launcher, main window, or both. Use this method to programmatically control the visibility of chat components. Syntax| Parameter | Type | Required | Description | |
|---|---|---|---|---|
| viewUpdate | string | object | Yes | Either a string key (‘launcher’ or ‘mainWindow’) or an object with optional launcher or mainWindow, or both boolean properties to control their visibility. |
Promise<void> - A promise that resolves when the view is updated.
Example
updateCustomHeaderItems()
Updates the display of custom items that appear in the chat header. It provides a container for custom items which can be either menu items or dropdown menus. Each item is configurable with a custom callback function that is called when a user selects an item. The method accepts an array of objects that define the properties of each custom header item. You can call this method anytime to change the current set of options. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| items | array | Yes | An array of custom header items to display. Each item is an object that defines the properties of the header element. |
| Property | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | A unique identifier for the header item. |
| text | string | Yes | The text to display for the header item. |
| align | string | No | The alignment of the header item. Possible values: left (default) or right. |
| icon | string | No | A URL or data URI to an icon image to display alongside the text. |
| type | string | Yes | The type of header item. Possible values: menu-item or dropdown. Default: menu-item. |
| onClick | function | Conditional | A callback function called when the button is clicked. Required for menu-item type. |
| items | array | Conditional | An array of submenu items for the dropdown. Required for dropdown type. |
| Property | Type | Required | Scope | Description |
|---|---|---|---|---|
| showSelectedAsTitle | boolean | No | float and custom form layout | When set to true, the detail view title automatically updates to show the text of the currently selected dropdown item. When set to false (default), the detail view title displays the dropdown’s main label. |
| Property | Type | Required | Scope | Description |
|---|---|---|---|---|
| id | string | Yes | - | A unique identifier for the submenu item. |
| text | string | Yes | - | The text to display for the submenu item. |
| align | string | No | - | The alignment of the submenu item. Possible values: left (default) or right. |
| icon | string | No | - | A URL or data URI to an icon image to display alongside the submenu item text. |
| onClick | function | Yes | - | A callback function called when the submenu item is clicked. |
void
Design Considerations
-
Form factor support: Chat header customization is available for all form factors:
fullscreen-overlay,float, andcustom. -
Side panel visibility: The side panel appears when at least one of the following features is enabled:
- Custom header items
- Chat thread list (controlled by
features.showThreadList) - Memory settings
-
Responsive behavior: Custom header items dynamically migrate between the header and side panel based on container width:
Viewport width Breakpoint Items in header Items in side panel < 320px xs 0 All items 320px - 671px sm 1 Remaining items 672px - 1055px md 2 Remaining items ≥ 1056px lg/xl/max 3 (maximum) Remaining items Example scenarios:The chat component uses a responsive layout with an optional side panel for rendering the chat thread list and custom header content. When implementing a custom layout, ensure the chat container height is at least 510px. In narrower viewports, the side panel collapses and the threads list container may not be rendered as expected.- 5 custom items at 1200px width: 3 in header, 2 in side panel
- 5 custom items at 800px width: 2 in header, 3 in side panel
- 5 custom items at 400px width: 1 in header, 4 in side panel
- 5 custom items at 280px width: 0 in header, 5 in side panel
- Float form factor: All custom items always appear in the side panel because Float has a fixed width of 380px.
-
Dropdown behavior: Dropdown items behave differently based on form layout:
Form layout Dropdown behavior Navigation pattern Float Detail view (slide-in) Back button + Toggle button Custom Detail view (slide-in) Back button + Toggle button Fullscreen Inline expansion Expand and collapse in place - Ordering: Items render in the UI in the same order they are defined in the configuration array.
- Navigation structure: Supports a maximum two-level hierarchy (main menu and one submenu level). Deeper nesting is not supported.
showSelectedAsTitle property, which updates the detail view title to display the selected item’s text. In the example, when a user selects “Spanish”, the detail view title automatically updates from “Language” to “Spanish”.
getCustomHeaderItems()
Retrieves the current set of custom header items that are configured in the chat widget. You can use the output to access and inspect the custom menu items that are currently displayed in the chat header. SyntaxCustomHeaderItem[] - An array of custom header item objects currently configured in the chat.
Example
updateLocale()
Changes the display language of the chat widget at runtime. By default, the locale is English (en).
Syntax
| Parameter | Type | Required | Description |
|---|---|---|---|
| locale | string | Yes | A locale string representing the desired language and region. |
| Language | Language Code |
|---|---|
| Chinese - Simplified | zh-CN |
| Chinese - Traditional | zh-TW |
| English | en |
| French | fr |
| German | de |
| Italian | it |
| Japanese | ja |
| Korean | ko |
| Portuguese - Brazil | pt-BR |
| Spanish | es |
Promise<void> - A promise that resolves when the locale is updated.
Example
getLocale()
Returns the language code for the current language that the chat widget uses, for example,en for English or fr for French. If a region is specified, it returns the language and region codes, for example, pt-BR for Brazilian Portuguese.
Syntax
string - The current locale code (e.g., en, fr, pt-BR).
Example
updateAuthToken()
Replaces the current JWT authentication token with a new one for continued secure communication. This is commonly used when tokens expire or are refreshed during a session. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | The new JWT token to be set in the chat configuration. |
void
Example
destroy()
Destroys the web chat instance and removes it from the page, cleaning up all associated resources and event listeners. Syntaxvoid
Example
on()
Subscribes a handler function to a specific chat event. The handler will be called every time the event occurs. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| eventName | string | Yes | The name of the event to subscribe to (e.g., 'send', 'receive', 'chat:ready'). |
| handler | function | Yes | The callback function to run when the event occurs. Receives (event, instance) as parameters. |
void
Common Events
-
chat:ready
Fired when the chat is fully loaded and ready. -
pre:send
Fired before a message is sent. -
send
Fired after a message is sent. -
pre:receive
Fired before a message is received. -
receive
Fired after a message is received. -
feedback
Fired when user provides feedback. -
userDefinedResponse
Fired for custom response types. -
pre:restartConversation
Fired before conversation restart. -
restartConversation
Fired after conversation restart. -
pre:threadLoaded
Fired before a thread is loaded from history. -
authTokenNeeded
Fired when authentication token needs refresh. -
view:pre:change
Fired before view state changes. -
view:change
Fired after view state changes.
once()
Subscribes a handler function to an event so it runs only once when that event occurs. After the event fires, the handler is automatically removed and is not called again. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| eventName | string | Yes | The name of the event to subscribe to. |
| handler | function | Yes | The callback function to run once when the event occurs. Receives (event, instance) as parameters. |
void
Example
off()
Removes a subscription to an event type. The specified handler will no longer be called when the event occurs. Syntax| Parameter | Type | Required | Description |
|---|---|---|---|
| eventName | string | Yes | The name of the event to unsubscribe from. |
| handler | function | Yes | The specific callback function to remove. Must be the same function reference that was used with on() or once(). |
void
Example

