Quriobot provides basic Javascrip API which you can use to control Quriobot's behavior

Note: as we are actively developing it, new features are added as we go, but we always try to keep backwards compartibility


If you include widget code in your page, global quriobot object will be available and it has such the methods:


  • quriobot.init(options) - initialize the bot if the explicit intialization was passed via widget URL API so your embed widget code will look like:
    • <script
          type="text/javascript"
          async
          defer
          src="https://quriobot.com/qb/widget/3MY12wr8gmd8AROG/NvRW9mA761E3BgZ4?init=explicit&onScriptLoad=quriobotLoaded">
      </script>

      this allows you to have full control the moment when bot appears on the screen (event the sticky avatar part). Please note that onScriptLoad parameter is passed, this is a global-scoped callback function which will be called once the quriobot widget script is fully loaded and so quriobot.init can be called
       

    • options - initialization options which will override those configured via Quriobot Control Room. Important use of it can be the possibility to pass the context to the bot for further use in the api methods. Then custom initialization will look like: 
      • <script
            type="text/javascript"
            async
            defer
            src="https://quriobot.com/qb/widget/3MY12wr8gmd8AROG/NvRW9mA761E3BgZ4?init=explicit&onScriptLoad=quriobotLoaded">
        </script>
        <script type="text/javascript">
           function quriobotLoaded(){
               quriobot.init({
                   context: {
                        myContextName: "my context value"
                   }
               })
           }
        </script>

        then you can use context in your script variables like quriobot.context.myContextName:


        • function(callback, variables) {
              callback(quriobot.context.myContextName)
          }

          and even more! QB automatically will prepare api methods for you for all your context values in form of:


          • {%api.qb_myContextName%}


            Note that if your context is a nested object, you can still access the nested values by flattening it using _ separator:


          • {%api.qb_myContextName_nested_value%}


          • You can also override context from the URL using qbprefix and JSON enconding:

            • http://my-qb-page.com?qb.myContextValue="my value"


  • quriobot.start([<bot path>])  - start the bot if it's not set to be autostarted on the page load, if bot path is passed and it's different from previous bot path, bot will be switched to a new path. Bot path is the last 2 parts of the embed code url, for example: https://quriobot.com/qb/widget/3MY12wr8gmd8AROG/NvRW9mA761E3BgZ4
  • quriobot.restart() - store the results for the current chat and restart the chat 
  • quriobot.show_frame()  - show the bot frame if it's not shown
  • quriobot.hide_frame()  - hide the bot frame if it's shown


Options object has such properties:


  • language - current bot language
  • autoStart - auto start timeout
  • autoStartCount - auto start after count
  • restoreState - restore bot state
  • restartAfterClose - restart after close
  • position - bot position
  • positionRtl - bot position for RTL languages
  • preventExitIfIncomplete - prevent bot exit if response is incomplete
  • visitor - visitor ID
  • botOffset: {
    top - bot offset top
    bottom - bot offset bottom
    }
  • stickyAvatarOffset: {
    bottom - sticky avatar offset bottom
    }
  • stickyAvatarPopup: {
    autoShowAfterClosed - auto show sticky avatar popup after bot is closed
    }
  • context - context data
  • showStickyAvatar - 'always' - always show sticky avatar, 'never' - never show, 'closed' - show after first close
  • ga - track bot actions with Google Analytics
  • preload - preload bot prior to actual starting
  • onAnswer - function(results, question, answer) on answer callback
  • onAnswerRedo - function(results, question, answer) - on answer redo callback
  • onExit - function(results) - on exit callback
  • onFinish -function(results) - on finish callback
  • onLeave - function(results) - on leave callback 
  • onRedo - function(results, question, answer) on redo callback
  • onReturn - function(results) - on return callback
  • onValidate - function(results, callback) - on validate callback
  • onSave - function(results, recaptchaResponse, callback) on save callback
  • onLoad - function(data) - on load callback
  • onQuestion - function(results, question) on question callback
  • onStart - function(results) on start callback





 

Quriobot 
Friendly & Fun 
Interact & Convert