Why is the offline form settings ignored if one department is on when another is off?

Answered

5 Comments

  • Heather Rommel
    Comment actions Permalink

    Hi Kelsey,

    I feel you! I think you can attend to this based on this article (and awesome comments): https://support.zendesk.com/hc/en-us/articles/360022192234

    I'm not much of a coder so my skin crawls when something is not native to the software, but in this case it does look pretty straightforward. I hope this helps to some degree.

    Side note - when you update hours I can envision that depending on the cache settings on the user's machine, it's possible the widget would misbehave until the end user clears cache or something.

    0
  • Kay
    Comment actions Permalink

    Hi Kelsey,

    There are multiple things at play here.
    I believe one of the things that is being overlooked is that you need some additional javascript for the widget.
    This code should check whether a department is still online, and if not, it will hide the widget.

    If you don't add this code, it means customer who already loaded your site/zendesk widget will get the offline form.
    This happens since you were online when they loaded, but went offline (in one or more departments) when they were idle or browsing your website.

    If I understand it correctly, can you please share your department names? To see if I can get you in the right direction with some sample code.

    0
  • Kelsey H
    Comment actions Permalink

    Sure, my departments are 

    • SetA
    • SetAA
    • SetI
    • SetD

     

    I'm not certain this is the case because on Tuesday we had a site go down and people were able to submit missed chats throughout the outage.

    0
  • Kay
    Comment actions Permalink

    ⚠️Fair warning: no guarantees on this code

    Here's how it works in a nutshell.

    • Chat is hidden on page load by default
    • All departments are checked
    • Visitor department is set based on url
    • Chat is toggled if the visitor's department is online
    • Every 10 seconds this process is repeated
    var all_departments;
    var department;
    var $custom_button_chat = $('.help-widget .chat');

    // map url to chat departments
    var url_path = window.location();
    var mapping = {
    'https://website.com/SetA' : 'SetA',
    'https://website.com/SetAA': 'SetAA',
    'https://website.com/SetI' : 'SetI',
    'https://website.com/SetD' : 'SetD',
    };

    autoControlDepartment = function controlDepartmentDropdown(){
    // remove dropdown from chat
    $zopim.livechat.departments.filter('');
    // set the correct visitor department
    $zopim.livechat.departments.setVisitorDepartment(department[0].name);
    }

    checkDepartmentStatus = function departmentStatus(){
    zE(function() {
    $zopim(function() {
    all_departments = $zopim.livechat.departments.getAllDepartments();
    department = all_departments.filter(function (department) {
    return department.name.toLowerCase() == mapping[url_path.toLowerCase();
    });
    });
    });
    }

    toggleChatButton = function chatButton(){
    if ( (!department) || ( department[0].status === "offline" || department[0].status === "away" )) {
    zE.hide();
    } else {
    zE.show();
    }
    }

    zE(function() {
    $zopim(function() {
    $zopim.livechat.hideAll();
    $zopim.livechat.setOnConnected(function() {

    // get all departments
    checkDepartmentStatus();
    autoControlDepartment();

    // hide the chat button if we are offline or away
    toggleChatButton();

    // re-check status of department every 10 seconds and toggle the custom chat button
    window.setInterval(checkDepartmentStatus, 10000);
    window.setInterval(toggleChatButton, 10000);
    });
    });
    zE.hide();
    });

    0
  • Brett - Community Manager
    Comment actions Permalink

    All things Chat AMA has ended and comments have now been closed. If you have any Chat related questions, you can create a new post in our Chat and Message - Troubleshooting and Q&A topic!

    0

Post is closed for comments.

Powered by Zendesk