You can check the current status of the chatbot 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 chatbot widget is in an open state:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('open')) {
console.log('Collectchat widget is open');
}
}Sample code for checking if the chatbot widget is in a closed state:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('closed')) {
console.log('Collectchat widget is closed');
}
}Sample code for checking if the user has completed at least one full conversation with the chatbot widget:
var collectchat = window.collectchat || {};
collectchat.ready = function() {
if (collectchat.is('completed')) {
console.log('Collectchat conversation is complete');
}
}Notice that this method is wrapped inside the collectchat.ready method.
