Recipe: Automatically route chats based on department online status Follow

Comments

12 comments

  • Avatar
    Intis Kalnins

    Would you just copy the "Using the Zopim chat widget" code above in full and add that to the page? I've tried, but when an agent from the department was online the chat widget didn't appear.
    Thanks.

  • Avatar
    Sergiu Birca

    Hi Intis,

    =1=
    If you want to use the Zopim Chat Widget, then you have to replace in the script the 'Zopim_key' string with the real Account key:

    window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
    d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
    _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
    $.src="//v2.zopim.com/?Zopim_key";z.t=+new Date;$.
    type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");

    You can find it here:
    https://dl.dropbox.com/s/hk0zpdus0cxyjks/Zopim_copy_account_key.png?dl=0

    =2=
    If you want to use the Zendesk Web Widget, then you will have to replace the 'mysubdomain' string (mysubdomain.zendesk.com) with your Zendesk instance subdomain.

    PS:
    Don't forget to also set the correct department name in the script (currently 'Australia').

    Hope it helps.

  • Avatar
    Charles

    Hi Sergiu,
    what if I don't want to make the widget disappear when the team is offline but switch to the offline "Leave a message" form ?
    Thanks for your advice.
    PS : I'm a Zendesk Enterprise user (not a Zopim standalone user).

  • Avatar
    Sergiu Birca

    Hey Charles,
    If you offer the chat service via the Zendesk Web Widget (second script), then you don't have to do anything (no need to modify the script). If the Contact Form option is enabled in the Web Widget settings, then the system will go straight to the Web Widget Contact form page (will skip the chat step, even if there are online agents in other departments).

    If you do it via the Zopim widget (the first script), then you will just have to remove this line:
    $zopim.livechat.hideAll();

    from the script + enable the Offline Form option in Zopim dashboard / Widget / Forms.

  • Avatar
    Jeremy Pinson (Edited )

    Hi Sergiu,

    I was sent here by a zopim tech but it doesn't really answer our question. We are trying something similar except we're triggering a proactive chat session. So, our trigger fires and sets a department however, we need to disable the trigger if nobody from the department is online. What currently happens is that if there is nobody online, the trigger still fires and the user ends up trying to chat to nobody. So we still want the user to be able to open a normal chat and talk to our other agents... just not run the proactive chat trigger that goes to a specific department. Hope you can help!

  • Avatar
    Sergiu Birca

    Hi Jeremy,

    You can not identify the status of the department via triggers. It can only be done via a script that uses the $zopim.livechat.departments.getDepartment  endpoint.

     

    Can you pls explain  in more details your use case:

    - Do you want to display the chat widget on the page automatically for all the users at the page load and at the same time if cernain conditions are met, fire a proactive trigger?

    OR

    you want the widget to be hidden by default and display it to specific customers at a specific time only as a result of a proactive trigger.

     

    - When you say "our other agents" => is the task to:

      - try to allocate the chat to a specific department first, and then, it that dept is offline, allocate it to a different department?

     

     

     

  • Avatar
    Jeremy Pinson

    Thanks for your reply, Sergiu. In our current configuration, the widget is hidden by default and users can start a chat by clicking a 'Chat Now' button in our header. We have also created a proactive chat trigger to fire only on a specific page after 30 seconds. It is configured to initiate a chat session with a specific department called 'Professional' however, when Professional is offline the trigger still fires and a chat session starts but the user has nobody to talk to. So, we need a way to disable the trigger on this specific page if the Professional department is offline... and still allow the user to initiate a chat session with any other agent as it currently works.

  • Avatar
    Sergiu Birca

    Hi Jeremy,

    ok, so this is what I suggest:

    =1=

    We will not use the triggers to set the department (it will be done via the script only);

    =2=

    We can not "disable" a trigger. We can only ensure that due to certain conditions, the trigger will not be applied to a chat session;

    =3=

    We will use tags instead. Via the following script, we will check the following conditions:

    a) if the Department1 status is online => add tag1

    b) if the department1 status is offline => check Department2 status.

    c)  if the Department2 status is online => add tag2

    d) if Department2  if offline => potentially hide or disabled (grey out) the 'Chat Now' button (you will have to build this yourself)

     

        $zopim(function() {

            setTimeout(function() {

                    $zopim.livechat.setOnConnected(function() {

                        var department_status = $zopim.livechat.departments.getDepartment('Department1');

                        if (department_status.status == 'offline') {

                            var department_status_2 = $zopim.livechat.departments.getDepartment('Department2');

                            if (department_status_2.status == 'offline') {

                                // hide the Zopim Widget or set the account to offline

                                //$zopim.livechat.hideAll();

                                $zopim.livechat.setStatus('offline');

                            } else {

                                // The department is Online (At least one agent in that department is Online)

                                $zopim.livechat.addTags("dept1_chat_redirected");

                                $zopim.livechat.departments.filter('');

                                $zopim.livechat.departments.setVisitorDepartment('Department2');

                                $zopim.livechat.theme.reload();

                            }

                        } else {

                            $zopim.livechat.addTags("dept1_chat");

                            $zopim.livechat.departments.filter('');

                            $zopim.livechat.departments.setVisitorDepartment('Department1');

                            $zopim.livechat.theme.reload();

                        }

                    });

                }, 3000) //3 secs

        });

     

     

    =4=

    Have 2 triggers in Chat:

    The critical condition in the first trigger: Visitor tag contains:  dept1_chat

    The critical condition in the second trigger:Visitor tag contains:   dept1_chat_redirected

     

     

    As a result of the above, the first trigger will be applied only if via the script, you will have the confirmation that the Dept1 is online (the dept1_chat tag is present), while the second trigger will work only if Dept1 is offline and Dept2 is online(the dept1_chat_redirected tag is present).

     

    Hope it helps.

  • Avatar
    Rameez Munir Bari

    Hi Sergiu,

    I am facing a issue in zopim in which offline zendesk tickets are not creating as my whole department is invisible for whole day. For Example: Department XYZ is Invisible for 23rd,Jan and they receive 20 overall chat during but only 15 offline zendesk tickets are been created there no zendesk ticket against 5. 

    I have talked with Support team of zendesk they say that

    "The way the widget may be working right now is that upon loading the webpage, the widget checks to see if agents are available in that department and if the page is idle for hours before the user tries to initiate a chat, the widget still thinks agents are available even if none are actually available. What we would recommend doing instead is changing your script so that instead of checking for available agents upon page load, have the widget check when the user clicks the widget to initiate a chat"

    We have Zopim triggers enabled that sets the department when the end-user first loads the widget.

    So can you please help what changing should i made in the script or is it some think else is the issue.

     

    Thanks

  • Avatar
    Sergiu Birca

    Hi Rameez,

    Lets take this offline. I will send you an email.

  • Avatar
    Nathan Miller (Edited )

    Hi Sergiu,

    This solution is terrific; however, we've run into one problem I'm hoping you can help us resolve.  When we use the method described to create a Support department, when all Support agents go Invisible the chat button does go away as it's supposed to.  However, if anybody is currently in a chat with an agent and all agents are invisible the current chat window for the visitor also disappears.

    We want to accommodate the end of the day when agents are going home, so they can go invisible, so no new chats come in, and finish their current chats.  Is there a method you see to accomplish this?

    We did already try changing $zopim.livechat.hideAll(); to $zopim.livechat.button.hide(); but this caused other problems (the contact form pops up on every single page load for visitors when we do that.

    Your help is much appreciated.

    UPDATE!

    It looks like we figured out a way to make this work.  We just wrapped the hideAll() within isChatting().  Example:

    if ($zopim.livechat.isChatting() == false) {
    $zopim.livechat.hideAll();
    }
  • Avatar
    Sergiu Birca

    Hi Nathan,

    yep, that is the solution (I should probably consider this use case as well (the department switching to offline for customers that are already engaged)).

     

    Depending on the implementation, there might be the case of displaying the .window element for customers that are already engaged in a chat, who keep accessing various pages on the website where the script is loaded.

    So potentially you might want to add to your if statement, an else:

    else{

     

    $zopim.livechat.window.show();

    }

Please sign in to leave a comment.

Powered by Zendesk