Segment end users to see live chat option

4 Kommentare

  • Kay
    Community Moderator

    Hi Nikita 👋

    Yep, this is perfectly doable.

    Here's how the script in your Help Center Template could work.
    Now you only need to add tag to the User in Zendesk Support. Either via a custom field that has a tag or via the tag property on the user.

    In the widget there is a setting to hide the widget when nobody's online.

    window.zESettings = {
    webWidget: {
    chat: {
    hideWhenOffline: true,
    suppress: true,
    }
    }
    };


    // only execute script if user is not "anonymous" (in other words, is logged in)
    if (HelpCenter.role !== 'anonymous') {
    if (HelpCenter.user.tags.includes('brand_y'){
    // add the widget script here to include your chat
    updateWebWidget();
    }
    }

    function updateWebWidget(){
    zE('webWidget', 'updateSettings', {
    webWidget: {
    chat: {
    suppress: false,
    }
    }
    });
    }
    0
  • Big Sur

    That's amazing, thanks so much!

    How would I add this to the Help Centre, do I just add the widget code and change it in the header.hbs?

     

    Thanks you,

    Nikita

    0
  • Big Sur

    I am just a little confused where the code needs to be included, I have added it now to the Web Widget but it still seems to show Live Chat to anonymous users.

     

    I just clicked the Add to help centre button on the widget and replaced the code with the one above and changed this bit to include the widget and changed the tag from brandy_y in your example to the actual tag:

    // add the widget script here to include your chat

    Any help would be appreciated!

    0
  • Big Sur

    Just as an update, I have managed to get it working with a help of a Zendesk agent:

    This code basically did what I needed, hope this helps anyone who wants to achieve a similar user journey:

    You need to add 2 pieces of code into script.js file in Help Centre.

    Place Part A before before the document.addEventListener('DOMContentLoaded', function() {​ line and Part B after it:

    window.zESettings = {
      webWidget: {
        chat: {
          suppress: true
        }
      }
    }
    if (HelpCenter.user.role !== 'anonymous') {
      if (HelpCenter.user.tags.includes('VIP')){
        zE('webWidget', 'updateSettings', {
          webWidget: {
            chat: {
              suppress: false
            }
          }
        })
      }
    }


    I have made further customisations from here to suppress talk and chat depending on the type of tagged user that's signed in. Btw, the tag name can be whatever you want it to be.

    Here is a good article that goes into more detail about the suppress option in the API: https://developer.zendesk.com/embeddables/docs/widget/settings

    Hope this helps!

    Nikita

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

Powered by Zendesk