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


4 Kommentare

  • Heather Rommel
    Community Moderator

    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.

  • Kay
    Community Moderator

    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.

  • Kelsey H

    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.

  • Kay
    Community Moderator

    ⚠️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
    // set the correct visitor department

    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" )) {
    } else {

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

    // get all departments

    // hide the chat button if we are offline or away

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


Post ist für Kommentare geschlossen.

Powered by Zendesk