How do I make my bot to perform a (google) search on my website?

An 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: and write down its Search engine ID
  2. Create a Google API key:, 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 to 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 = "[API key]&cx=[Search engine ID]&q=" + encodeURIComponent(searchInput);
          quriobot.ajax(url, function (responseText) {
            var response = JSON.parse(responseText);
            var result = response.items ? (item) {
              return '<article><a target="_blank" href="' + item.formattedUrl + '">' + item.htmlTitle + '</a><br>' + item.htmlSnippet + '</article>'
            }).join('<br>') : 'no results found, try to change your search criteria'
            callback('<div class="panel--wrapper">' + result + '</div>')
  5. Add a fold-out step, name itsearch results, this will be used to display the search results
    1. Select the display type -> HTML and use the previously created variable:
      1. {{searchResults}}

Edit this page