(Legacy Chat) How do I change the status of Chat in the widget based on department availability?

Return to top
Have more questions? Submit a request

3 Comments

  • dronavalli. srichandra

    Though the above code we are just displaying the department status as Offline but how do we disable the chat at the same time.?

    1
  • Dan Ross
    Community Moderator

    Hey dronavalli. srichandra

     

    You likely want to avoid using the older $zopim API and consider the news Web Widget syntax

    Zendesk wrote a great article demonstrating how to test a department status and disable chat if they're offline.

     

    https://support.zendesk.com/hc/en-us/articles/360035633073-Can-I-configure-the-Web-Widget-to-present-Chat-on-my-webpage-only-when-a-specific-department-is-online-

     

    Hope that helps!

    0
  • dronavalli. srichandra

    Yeah i agree , Initially i wrote the Web Widget Syntax which is Working perfectly fine in the Online Compiler.

     Below is the code i'm using for reference.

    <script>
    zE('webWidget:on', 'chat:departmentStatus', function(dept) {
    if (dept.name === 'Agency Marketing Support' && dept.status === 'online') {
    console.log(dept.name + ' is ' + dept.status); //optional logging
    zE('webWidget', 'updateSettings', {
    webWidget: {
    chat: {
    departments: {
    enabled: [''],
    select: 'Agency Marketing Support'
    },
    suppress: false
    }
    }
    });
    } else if (dept.name === 'Agency Marketing Support' && dept.status !== 'online') {
    console.log(dept.name + ' is ' + dept.status); //optional logging
    zE('webWidget', 'updateSettings', {
    webWidget: {
    chat: {
    suppress: true
    }
    }
    });
    }
    });
    </script>

    When i'm using the above script in our sites it is displaying all the departments which is bad .

    So at that point i jumped into the $zopim , working on the below code.

     

    <script type="text/javascript"> zE(function(){ $zopim(function() { $zopim.livechat.departments.filter('Media Concierge'); $zopim.livechat.setOnConnected(function() {
    var dep1 = $zopim.livechat.departments.getDepartment('Media Concierge');
    var dep2 = $zopim.livechat.departments.getDepartment('Agency Marketing Support');
    if(dep2.status == "offline")
    {
    $zopim.livechat.setStatus('offline'); }
    else{ $zopim.livechat.button.show(); } }); }); }); </script>

    After using the $zopim script our site is responding based in the conditions.

    In the above zopim , only thing is while using $zopim.livechat.departments.setVisitorDepartment , i dont want to show the department field on the chat.

     

    0

Please sign in to leave a comment.

Powered by Zendesk