How to use the data from an external API endpoint in your bot chat-texts and responses

As described here, It’s possible to use custom Function results in your bot chat texts and responses. This solution describes how to enrich your QB with data from an arbitrary HTTP API endpoint.

We will make use of the Script variables and such utility :

quriobot.ajax(url, callback, data, headers) - perform http requests (GET if no data parameter is passed)

Step 1: Enable developer mode

Step 2: Create a script variable called example:

function(callback, variables) {
        function(responseText) {
            var response = JSON.parse(responseText);

In this case, we assume that the API endpoint returns the JSON response in the form:

     "yourField": "value"

Step 3: You can now use {{example}} in any chat text, response message, response action

Note: Depending on the external service you want to get data from from the JS function might be different, so we made it easier for you to call external HTTP endpoints from QB without relying on any external JavaScript libraries.

Edit this page