Live chat Javascript API

Please note, this feature is currently in internal testing and is not officially available yet. Please follow our changelog for the latest updates.

Overview

You can use the JavaScript API to control FIRST LINE live chat, perform various useful and fun operations, and fully utilize the FIRST LINE live chat features. For example, decide how the live chat is displayed based on website customer behavior.

Here are some example actions that can help you perform these operations:

Clear user data

When a user logs out of your application, you can clear the user's data. Ensure that users of shared computers and browsers cannot view each other's conversations.

Automatically open the chat window

Decide how the live chat is displayed based on user behavior. For example, when a user clicks the purchase button, you can open the chat window immediately.

The JavaScript API is built into the FIRST LINE live chat launcher. No installation or enabling of additional components is required; you can start using it directly without any specific configuration. Please note that the live chat JavaScript API is limited to live chats created via the embed code method. External link methods may not be applicable in all cases.

Methods

$FirstLine('shutdown')

If you use live chat together with other products, you can call the 'shutdown' method to clear user-related information when a user logs out of your application. Otherwise, cookies and localStorage on the logged-in device will retain these contact details. Using the shutdown method will effectively clear user data to ensure privacy.

$FirstLine('shutdown')

$FirstLine('open')

This method will open the live chat conversation window.

$FirstLine('close')

This method will close the live chat conversation window.

$FirstLine('show')

This method will show the entire live chat.

$FirstLine('hide')

This method will hide the entire live chat.

$FirstLine('onShow')

When the live chat conversation window is shown, you can specify a trigger event. This method requires a function as a parameter.

$FirstLine('onHide')

When the live chat conversation window is shown, you can specify a trigger event. This method requires a function as a parameter.

$FirstLine('onUnreadCountChange')

When the live chat conversation window is shown, you can specify a trigger event. This method requires a function as a parameter.

$FirstLine('showEnticeMessage')

Display an entice message and pass a string-type message as the second parameter. This message will replace the currently displayed welcome message.

Last updated