Wednesday, April 4, 2012

get agent status in zopim using javascript

I implemented zopim in a site and had to change class of a div according to the current agent's status.

 <div class="chatbox"   onclick="$zopim.livechat.window.toggle();">sow chat</div>

<script type="text/javascript">
//YOUR ZOPIM SCRIPT HERE
</script>

$zopim(function() {
    $zopim.livechat
      .setOnStatus(updateStatus);
    });

//updatestatus function
 function updateStatus(s) //NOTICE  "s" here it contains agent's current status
  {
  
      switch(s)
      {
        case 'online':
            jQuery('.chatbox').addClass('online');
        break;
        case 'offline':
            jQuery('.chatbox').removeClass('online');
        break;
        case 'away':
            jQuery('.chatbox').removeClass('online').addClass('away');
        break;
  }

No comments:

Post a Comment