Providing targeted support with Zendesk Chat Follow

Comments

13 comments

  • Avatar
    Jonathan Semones

    Does this script still work?  I tried adding it to my help center using both the regular zopim chat option and the full blown zendesk widget and neither of them seemed to work.  When i was signed out I could still see the widgets.

    the only thing i changed about the script was changing the 'vip' tag to an 'active_client' tag that we use.

    It seems like it messes up some of my other js as well.

  • Avatar
    Sergiu Birca

    Hey Jonathan,

    this works for me:

    var user_tags = HelpCenter.user.tags;
    var vip = "vip";
    if ($.inArray(vip, user_tags) === 1) {


    window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(e){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("https://assets.zendesk.com/embeddable_framework/main.js","mycompany.zendesk.com");


    zE(function(){
    zE.hide();
    $zopim(function() {
    setTimeout(function() {
    if ($zopim.livechat.isChatting() == true) {
    console.log("Chat is running!"); 
    $zopim.livechat.window.show();
    } else {
    console.log("Chat is not running!"); 
    zE.show(); // Show the Web Widget

    }, 1500);

    });
    });
    }

     

    Please place it in the JS section of your HC.

    Hope it helps.

  • Avatar
    Jonathan Semones

    After looking at it again i realized that the original scripts required the Zopim API, does your @sergiu?  Our level of Zopim doesn't include the API.

  • Avatar
    Sergiu Birca

    Jonathan,

    There are different APIs. The one you probably mean is Zopim REST API that is restricted for specific plans. In the above script I used Zopim JS API that is available on all the plans.

     

    https://api.zopim.com/files/meshim/widget/controllers/LiveChatAPI-js.html

  • Avatar
    Jonathan Semones

    Oh, Cool.  Well i'm not sure what i'm doing wrong then.  I placed that new script at the end of my JS page and replaced vip with active_client and replaced the mycompany part.  When i turn off the zopim chat setting in the Helpcenter settings the zopim widget disappears, when i turn it on it appears even when i am logged off.  Am i using the wrong widget, should i be using the full blown zendesk widget?

  • Avatar
    Sergiu Birca

    Jonathan,

    The script is for the Web Widget (that has as a component the Zopim chat), not the Zopim widget.

    Also, please uncheck the Zopim checkbox in the HC Settings. 

    Please the scrip just under this line in the JS page:

    $(document).ready(function() {

     

    Then as a Zopim agent login into Zopim and set yourself as Online (status). Simulate the end user interaction in an incognito window or a different browser (don't do it in the same browser where you are logged in as agent).

     

     

     

  • Avatar
    Jonathan Semones

    Is there a way to do this with the zopim widget?

    We are trying to require customers to log in before beginning a chat (that way our agents are not trying to answer sales questions, which is not part of their job).  The problem is that i use the zendesk widget on other sites.  If I enable chat in the zendesk widget it will enable it everywhere.

  • Avatar
    Sergiu Birca

    If needed, I can provide a script that will use the Zopim widget, but I would suggest you to have consistency and use the same widget on all the portals.

     

    To suppress the Chat option on specific websites / pages, you can use our new Web Widget API options (currently in beta):

    https://support.zendesk.com/hc/en-us/community/posts/218033707-Start-here-Web-Widget-customizations-beta

    webWidget: {
       chat: {
         suppress: true
       },

     

    To subscribe to beta:

    https://goo.gl/forms/cbeRc3ZTBywaK1Qi1

     






  • Avatar
    Jonathan Semones

    Can I get that script to use it with the zopim widget?  

     

    Currently we only use the zendesk widget to enter tickets from our other websites and don't have plans to include chat from there any time soon.  I did sign up for the beta, but it will be awhile before I can integrate that with the other sites.

     

    Thank you for you help.

     

  • Avatar
    Sergiu Birca

    Hey Jonathan,

    Here is the script.

    Before releasing it, please activate this option:

    If you won't find it in your menu, please:

    =1=

    Disable the chat option in your Web Widget Settings.

    =2=

    After 10 minutes, log out from Zopim and then log back in. That menu option should appear in the list.

     

     

    The script:

    var user_tags = HelpCenter.user.tags;
    var vip = "vip";
    if ($.inArray(vip, user_tags) === 1) {


    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/?account_key';z.t=+new Date;$.
    type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');


    $zopim(function() {
    setTimeout(function() {
    if ($zopim.livechat.isChatting() == true) {
    console.log("Chat is running!");
    $zopim.livechat.window.show();
    } else {
    console.log("Chat is not running!");
    $zopim.livechat.button.show();
    }
    }, 1500);

    });

    }

     

     

    the account key you can find here:

     

     

  • Avatar
    Jonathan Semones

    Hey Sergiu,

    We tweaked that script a little and got it working for us.  However, we found when we started that there was one problem.  When we click on the button the screen chat screen pops up, but when we click the collapse button on the screen it disappears instead of just collapsing down to the button again. When we got done tweaking it the problem was still there.  Any idea how to fix that?  

     

  • Avatar
    Sergiu Birca

    Hey Jonathan,

    It's because we use the Hide option. It automatically hides the widget.

    Use the onHide JS API endpoint to identify the moment when the visitor clicks to hide the chat window. Then use button.show() to display the button.

     

    Add this bit to your script:

     

    $zopim.livechat.window.onHide(show_button);

    function show_button() {
    $zopim.livechat.button.show();
    }

     

  • Avatar
    Jonathan Semones

    Hey Sergiu,

    That did it!  Thank you for all your help.  It is working perfectly now.

Please sign in to leave a comment.

Powered by Zendesk