You can check the current status of the chat widget using the following method.
collectchat.is(key)
This method uses the parameter key, which can check for three possible states:
- open — check if the widget is in an open state
- closed — check if the widget is in a closed state
- completed — check if the user has completed the conversation in the widget at least once
Sample code for checking if the chat widget is in an open state:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('open')) {
console.log('Collect.chat widget is open');
}
}Sample code for checking if the chat widget is in a closed state:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('closed')) {
console.log('Collect.chat widget is closed');
}
}Sample code for checking if the user has completed at least one full conversation with the chat widget:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('completed')) {
console.log('Collect.chat conversation is complete');
}
}Notice that this method is wrapped inside the collectchat.ready method.
