Hide the chat widget when all operators are offline

To hide the chat widget when all operators are Offline, make the following changes to the installation code:

Step #1

Add session: { autoStart: false } to the block window.chaportConfig after appId, so that the block will look like this:

window.chaportConfig = {
  appId: '56e9162264e94eb633a095fb',
  session: {
    autoStart: false
  }
}

Step #2

Add these lines after

<!-- End of Chaport Live Chat code -->
:

window.chaport.q('isOnline', function (isOnline) {
  if (isOnline) window.chaport.startSession();
});
window.chaport.on(‘chat.onlineChange’, function (isOnline) {
  if (isOnline) window.chaport.startSession();
  else window.chaport.stopSession();
});

Please note: This code is a part of JavaScript API that is available only on the PRO plan.