Skip to main content
The Chat Widget JavaScript API extends the standard Text widget through the global LiveChatWidget object available on your page.

Before you start

The API is available through the global LiveChatWidget object initialized by the widget installation code. If the widget isn’t installed on your website, copy the code from website settings or use the snippet below. Replace <ORGANIZATION_ID> with your organization ID.
Text widget code

API functions

The LiveChatWidget object provides five functions:
  • on registers a callback for an event.
  • once registers a callback for one occurrence of an event, then removes it.
  • off removes a callback registered with on.
  • call invokes a method or setter.
  • get retrieves data from the widget.
Pass the method name and its data to the appropriate function:
For example, use the following call to set the customer’s name to John Doe:

Asynchronous initialization

By default, the widget loads when the installation code runs. To load it after an interaction or another event in your website, set window.__lc.asyncInit to true before the rest of the installation code.
The installation code still creates the LiveChatWidget object, but it doesn’t load the widget resources or trigger the ready callback. Call LiveChatWidget.init() when you want to load the widget:

Chat Widget methods

The reference separates the API by how you interact with the widget. For a broader comparison, see Chat Widget APIs.