Displaying or hiding the chat bubble based on status

Note: This guide applies only to the Chat widget from Chat-only accounts, not from Chat+Support accounts. See About Chat account types in Zendesk help.

There are two APIs that manipulate the chat bubble's visibility:

  • API to make the bubble visible:

    $zopim.livechat.bubble.show(); 

  • API to hide the bubble:

    $zopim.livechat.bubble.hide();

The following API, which detects the status of the widget, is useful with the above APIs:

$zopim.livechat.setOnStatus(bubble);

 Paste the following code right beneath your Zopim live chat script and it'll start working instantly.

<script type="text/javascript">  $zopim(function(){  $zopim.livechat.setOnStatus(bubble);
function bubble(status){
if(status=='online')  {
//embed the API which allows the bubble to be shown here, it's displayed whenever the chat status is online  $zopim.livechat.bubble.show();
}  else if(status=='away')  {
//embed the API which hides the bubble. This part of the code runs only when the chat status is away  $zopim.livechat.bubble.hide();
}  else if(status=='offline')  {
//embed the API which hides the bubble. This part of the code runs only when the chat status is offline  $zopim.livechat.bubble.hide();
}
}
});  </script>

The script above shows the bubble if the chat status is online only. It will hide the bubble if the chat status is either offline or away.