LiveChatWidget.call(). Getters read data with LiveChatWidget.get(), and callbacks subscribe to widget events with LiveChatWidget.on().
Available methods
Interactions
JavaScript API interaction methods allow you to create custom ways to interact with a widget. For example, you can hide your widget based on specific conditions or trigger a sales tracker defined earlier in Text. You can also run themaximize, minimize, and send_message actions with HTML attributes.
Maximize
Maximizes the chat widget.messageDraft param.
startChat param.
messageDraft.
Send message
Sends a message on the customer’s behalf and maximizes the chat widget. Use it to turn an element on your page, such as a suggested question, into a message the customer sends with one click.text is empty, or when the group is offline and continuous chats are turned off. If a pre-chat form is enabled, the message becomes a draft and is sent once the form is submitted.
Payload
Minimize
Minimizes the chat widget.Hide
Hides the chat widget on the site. You will need to use either ‘maximize’, or ‘minimize’ API calls to show it afterwards.Destroy
Destroys the chat widget. It won’t be available for further actions until the window is refreshed.Hide greeting
Hides the currently displayed greeting. In order to hide particular greeting you can listen tonew_event or greeting_hidden callbacks to know when greeting with specified id or uniqueId appears and disappears accordingly.
Trigger sales tracker
Triggers a sales tracker created in Text and passes over data about a sale. The data is then visible in Text’s Reports and Archives. For more information about how Sales Tracker works and how to set it up on your website, check out our official Help Center article: How Sales Tracker works in practice.Ecommerce
Ecommerce methods send cart and order data from your store to Text.Track sales event
Sends an ecommerce event. For active chats, cart and order events appear in the agent’s Inbox in real time. Order events also feed the All Sales, AI Agent Sales, and Sales conversion reports. In reports, data syncs once an hour.store_order_was_created
Use on your order confirmation page after a purchase is completed.
store_product_added_to_cart
Use when a customer adds an item to the cart.
store_product_removed_from_cart
Use when a customer removes an item from the cart.
Set customer cart
Sends the customer’s cart to the chat widget so agents can see it in the Inbox in real time. Call the method whenever the cart changes. There is no separate action to clear the cart. To clear it, call the method with an emptyitems array.
items array:
14999 for USD 149.99. The currency value determines how the amounts are interpreted. Don’t send non-integer numbers or strings.
Payload
Items
Getters
You can use getters to fetch the data from the chat widget.Get state
Returns the chat widget state. This includes Widget visibility and license availability.Get customer data
Returns a filtered list of customer data.Get chat data
Returns the chat data, which contains the current chat and thread IDs.Setters
Various data can be sent over to the Text integration so that your agents can use it.Set session variables
Creates new session variables, or replaces the ones set previously.Update session variables
Changes the values of your session variables. Note that existing variables won’t be replaced. The new session variables will be included together with the ones set previously.Set customer name
Sets the customer’s name.Set customer email
Sets the customer’s email address.Set customer phone number
Sets the customer’s phone number.Callbacks
Callbacks allow you to react to the events triggered by the chat widget. You can use them to add custom behaviors when certain events happen. This can be accomplished by subscribing a callback with the API.On ready
Runs when the chat widget has finished loading. If the chat widget is already loaded, the provided handler function runs immediately. With this callback, you will receive the chat widget state and customer data as if requested by their getters. PayloadOn availability changed
Runs when availability changes for the current group. PayloadOn visibility changed
Runs when the chat widget visibility changes. This applies to both user actions like maximizing or minimizing the window as well as hiding or showing the chat widget through the use of this API. PayloadOn customer status changed
Runs when the customer’s status changes. This can be used to track the following info:- If and when Customers are being invited to chat
- If Customers are already chatting
- If they are waiting for an agent to become available in the queue
On customer data changed
Runs every time the customer data changes. The payload matches the Get customer data response.On new event
Runs for both incoming and outgoing events. Payload- General
- Greeting
On form submitted
Runs after the customer submits a form in the chat. PayloadOn rating submitted
Runs after the customer rates the chat or cancels the previous rating. PayloadOn greeting displayed
Runs after the chat widget displays the greeting to the customer. PayloadOn greeting hidden
Runs after the customer or thehide_greeting method cancels the greeting.
Payload