How to add context definitions to scripts on a website

Add the context definition to the widget script on your website to start using contextual answers.

Make sure you have set up contexts in your account.

Once your knowledge base is set up to work with contextual answers, add the contextual answers' API code to your website as follows:

  1. Find the Bold360 AIwidget script on your web page and add the contextual answers at the end of the script.

    Example:

    In this script the device type context category with Android value is added. See the relevant part in bold.

    <!-- nanorep floating widget --> <script>!function(t,e,o,c,n,a){var s=window.nanorep=window.nanorep||{};s=s[e]=s[e]||{},s.apiHost=a,s.host=n,s.path=c,s.account=t,s.protocol= "https:"===location.protocol? "https:":"http:",s.on=s.on||function(){s._calls=s._calls||[],s._calls.push([].slice.call(arguments))};var p=s.protocol+ "//"+n+c+o+"?account="+t,l=document.createElement("script");l.async=l.defer=!0,l.setAttribute("src",p), document.getElementsByTagName("head") [0].appendChild(l)}("","floatingWidget","floating-widget.js","/web/",".nanorep.co");</script> <script> nanorep.floatingWidget.on({             init: function()                         this.setContext({"DeviceType":"Android"});             } }); </script> <!-- //nanorep floating widget -->
    Important: If you are a Bold360 customer who integrated Bold360 Agent and Bold360 AI, use the following, extended code instead:
    <!-- nanorep floating widget -->
    <script>!function(t,e,o,c,n,a){var s=window.nanorep=window.nanorep||{};s=s[e]=s[e]||{},s.apiHost=a,s.host=n,s.path=c,s.account=t,s.protocol=
    "https:"===location.protocol? "https:":"http:",s.on=s.on||function(){s._calls=s._calls||[],s._calls.push([].slice.call(arguments))};var p=s.protocol+
    "//"+n+c+o+"?account="+t,l=document.createElement("script");l.async=l.defer=!0,l.setAttribute("src",p), document.getElementsByTagName("head")[0]
    .appendChild(l)}("","floatingWidget","floating-widget.js","/web/",".nanorep.co");</script>
    <script>
    window.nanorep =window.nanorep || {};
    nanorep.floatingWidget = nanorep.floatingWidget || {};
    nanorep.floatingWidget._calls = nanorep.floatingWidget._calls || [];
    nanorep.floatingWidget._calls.push(
      [
        'init',
        function () {
          this.setContext({"Category":"Value"});
        }
      ]
    );
    </script> <script> nanorep.floatingWidget.on({             init: function()                         this.setContext({"DeviceType":"Android"});             } }); </script>
    <!-- //nanorep floating widget -->
  2. Make sure contextual answers work by searching for an answer with contextual values.

    Find information on how to add context to an article here.