Example use case can be the FAQ bot which has a fallback to make a full text search within your website or knowledge base (wiki) and presents the results directly inside the bot to keep the user focus.

In order to implement this, we'll make use of short text step, fold-out step and bot variables:


  1. Create a google custom search engine for your website: https://cse.google.com/cse/create/new and write down it's Search engine ID
  2. Create a google API key: https://console.developers.google.com/apis/credentials, note that it's recommended to restrict it for your website only. Write down the API key.
  3. Add a short text step, name it search input, this will be used to ask for the search query
  4. Create such bot variables:
    1. searchInput, (type step), select the 'search input' step
    2. searchResults (type script), NOTE that you need to replace [API key] and [Search engine ID] with the previously obtained API key and Search engine ID
      1. function(callback, variables) {
          var searchInput = variables.searchInput.value;
          var url = "https://www.googleapis.com/customsearch/v1?key=[API key]&cx=[Search engine ID]&q=" + encodeURIComponent(searchInput);
          quriobot.ajax(url, function(responseText) {
            var response = JSON.parse(responseText);
            callback(
              response.items.map(function(item) {
            return '<a target="_blank" href="' + item.htmlFormattedUrl + '">' + item.htmlTitle +'</a><br>' + item.htmlSnippet
              }).join('<br><br>'))
          })
        }
  5. Add a fold-out step, name it search results, this will be used to display the search results
    1. Select the display type -> HTML and use the previously created variable:
      1. {{searchResults}}