admin:online-platform-cms:3rd-party-scripts:freshchat

This is an old revision of the document!


Freshchat

To use freshchat widget add this code to the custom script section:

// BEGINNING OF FRESHCHAT WIDGET //
  var freshchathost = "<FRESHCHAT_HOST>";
  var freshchattoken = "<FRESHCHAT_TOKEN>";
  function initFreshChat() {
    window.fcWidget.init({
      token: freshchattoken,
      host: freshchathost
    });
  }
  function initialize(i,t){var e;i.getElementById(t)?initFreshChat():((e=i.createElement("script")).id=t,e.async=!0,e.src=freshchathost+"/js/widget.js",e.onload=initFreshChat,i.head.appendChild(e))}function initiateCall(){initialize(document,"freshchat-js-sdk")}initiateCall();

  document.body.addEventListener("userLogIn", function(e){
    const user = e.detail;
    window.fcWidget.setExternalId(user.id);
    window.fcWidget.user.setFirstName(user.displayName);
    window.fcWidget.user.setEmail(user.email);
  });
// END OF FRESHCHAT WIDGET //

To make it work for your case, insert freshchat host and token in these lines only:

  var freshchathost = "<FRESHCHAT_HOST>";
  var freshchattoken = "<FRESHCHAT_TOKEN>";
  • admin/online-platform-cms/3rd-party-scripts/freshchat.1592376469.txt.gz
  • Last modified: 2020/06/17 06:47
  • (external edit)