Live chat Javascript API
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.
Methods
Please note that methods should be called after the JavaScript API has loaded or at a stage when JavaScript can execute. In some browser scenarios, actions may fail, for example if attempting to call a method before the page is closed.
$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')After using this method, if you need to use live chat again, you must recreate a new live chat via the embed code or similar method.
$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