Chatlayer Documentation
Get in touchAbout Chatlayer
  • Welcome
  • What's new
  • Send feedback
  • start quickly
    • Leadzy tutorial
      • 0. Introduction
      • 1. New bot, new block
      • 2. Understand your users
      • 3. Collect and display user input
      • 4. Steer the conversation with Conditions
      • 5. Empower your bot with Actions
      • 6. Set up a channel and publish your bot
    • Templates
      • Banking
      • E-Commerce Returns
      • E-Bike Shop
      • E-Scooter Support
      • Feedback
      • Find Nearest Location
      • GPT
      • 🆕Gym
      • Job applications
      • Knowledge base AI template
      • Lead generation
      • 🆕NPS
      • Restaurant
      • Retail
  • navigation
    • Analytics
      • Dashboard
      • Customers
      • Conversations
      • User flow
      • Intents
      • 🆕Funnels [Beta]
    • Bot builder
      • Flows
        • Canvas functionalities
        • Collaborate with team members
        • Manage your flows
        • 🆕[Beta] Export and import flows
      • Bot dialogs view
      • Translations
      • Events
    • NLP
      • Dashboard
      • Intents
      • Expressions
      • Entities
      • Train
      • NLP settings
      • Improve
    • Knowledge base AI
      • Add content to your KBAI
      • Build your KBAI flow
      • Use your KBAI source URL in a button
      • Use tags to limit your KBAI content
      • 🆕Use Tables to store your KBAI questions
      • 🆕Manage handover where KBAI is unsatisfactory
    • History
      • Conversations
      • Execution logs
      • Versions
    • Channels
    • Tables
      • Create a table with records
      • Column types
      • Operate on your records
        • Insert record
        • Update record
        • Retrieve record
        • Delete record
      • API
    • Settings
      • Bot settings
      • Offloading
      • Variables
      • Voice
      • Import/Export
  • build your bot
    • Conversation design
      • Plan your bot
      • Conversation design workflow
    • Flow logic
      • Blocks
        • Message
        • Condition
        • Collect input
        • Action
      • Go-to connections
    • 🆕Emulator
    • Tips & best practices
      • Route your flow depending on the time
      • Improve the Not understood block
        • How to create better not understood messages
        • Not understood counter
        • Not understood Google search
      • Go to previous block
      • Recognizing a returning user
      • Skip introduction message
      • Route your flow depending on the channel
      • Reuse flows
      • Connect two bots to each other
  • understand users
    • Natural language processing (NLP)
      • Basic NLP concepts
      • Detect information with entities
        • Match entities
        • Contextual entities
        • System entities
        • Composite entities
      • NLP best practices
        • Word order and diversity of expressions
      • AI intent booster
      • Train your NLP
      • Context
      • NLP import & export
      • Sentiment analysis
    • Languages
      • Supported languages
      • Make your bot multilingual
      • Change language within the conversation
  • set up channels
    • Add a channel to your bot
    • All channels
      • 🚨Facebook Messenger [Deprecated soon]
        • Facebook Admin Removal
        • Facebook Webview Whitelisting
        • Facebook Messenger API updates for Europe
      • 🚨Google Assistant [Deprecated soon]
      • Webhook
      • Web
        • 🚨Web V1 [Deprecated]
          • Customize web widget
          • Live example web widget
        • 🆕Web V2
          • 🆕From Web V1 to V2
          • 🆕Web V2 methods and options
    • Sinch Conversation API
      • Configure your Sinch Conversation API
      • 🆕 Make the most of RCS with Carousels
      • WhatsApp Business API
  • integrate & code
    • API calls
      • Configure your API integration
      • Advanced API features
      • V1 API Reference
      • Custom integrations 101
    • Code editor
      • [Example] Sending data to Airtable (POST)
      • [Example] Retrieving data from Airtable (GET)
      • [Example] Making SOAP requests
    • App integrations
      • Airtable
      • Freshdesk
      • Freshdesk Messaging
      • 🆕Gmail
      • Intercom
      • Mailgun
      • OpenAI: GPT-3, ChatGPT and GPT-4
      • Salesforce
      • 🆕Slack
      • Topdesk
      • Zendesk Support
      • Zendesk Sunshine (beta)
    • 🆕Expression syntax
    • Human handover & live chat
      • Sinch Contact Pro
      • #Interact
      • Genesys Cloud
      • Offloading Webhook
      • Salesforce Service Cloud
      • Sparkcentral by Hootsuite
      • Zendesk Chat
    • Chatlayer messages specifications
  • Publish
    • Publish your bot
      • Publish a flow
  • Analyze & maintain
    • Analytics definitions
    • Data retention
    • Maintenance
    • Session
    • Track events for analytics
  • VOICE
    • 🆕Send bot response as audio
    • Voicebots
      • Create a voicebot
      • Voicebot-specific actions
      • Test your voicebot
      • From chat to voice
  • access & support
    • Identity & Access
      • Single Sign-On (SAML SSO)
    • Billing & subscription
    • Get in touch
    • Chatlayer glossary
    • SaaS Regions & IP Ranges
    • Status
    • Debug your bot
      • No correct response
      • Collect input not working
      • Video isn't working
Powered by GitBook
On this page
  • Google Programmable Search
  • Action block Expression Lookup

Was this helpful?

  1. build your bot
  2. Tips & best practices
  3. Improve the Not understood block

Not understood Google search

PreviousNot understood counterNextGo to previous block

Last updated 1 year ago

Was this helpful?

What if a user asks a question that is outside of the bot's scope? Or what if your bot can't understand the user input? One of the things you can do is show a 'not understood' block message, which usually leads to an offloading action. It works well, but what if there's a more user-friendly way for the user to still get the answer to their question without offloading or leaving the bot?

This tutorial will show you how to create a search engine lookup on your own website using the user input from your chatbot! We will walk you through the steps of creating a lookup search on your website, using Google's 'Programmable Search'.

For example, the user asks about 'opening hours' in the chatbot. However, this is not recognized because there isn't such an intent in the bot. So, the bot will go to 'not understood'. Then, a search will be done on your website using the input. Google will search for '{your website} + opening hours' and show the first five results in a carousel in the chatbot.

Google Programmable Search

Action block Expression Lookup

Now we can put the Lookup with the information of the Google Engine in an Action block in the chatbot:

Add the following arguments to your Action block:

  • NLP: this is the variable what we are looking for, so the input the user has given and resulted in a 'not understood'

  • googleAPIKey: this you retrieved using the link mentioned above

  • googleEngine: The 'Search engine ID' on the search engine page above

Once that's done, add the following code in the same Action block. In line 15, paste a fallback image there, for example your company logo. This image will be shown in the carousel if the search does not retrieve an image.

const { nlp, googleEngine, googleAPIKey } = args;

const { expression } = nlp;

const url = `https://www.googleapis.com/customsearch/v1?key=${googleAPIKey}&cx=${googleEngine}&q=${expression}`;

const searchResult = await fetch(url).then(res => res.json());

const elements = _.get(searchResult, 'items', [])
  .slice(0, 5)
  .map(result => {
    const imageUrl = _.get(
      result,
      'pagemap.cse_thumbnail[0].src',
      'https:// {your image here} .png'
    );
    return {
      title: result.title,
      subTitle: result.snippet,
      ...(imageUrl ? { imageUrl } : {}),
      buttons: [
        {
          title: result.title,
          type: 'web_url',
          url: result.link,
          payload: {},
        },
      ],
    };
  });

const builder = ChatlayerResponseBuilder();

if (elements.length) {
  builder.addCarousel(elements);
} else {
  builder.addMessage('Nothing found!');
}

builder.send();

This code block already takes care of the carousel, so there's no need to add an extra Message block. Now the final thing to do is link this to the 'Not understood' bot message:

  • Change the text message with {internal.nlp.expression}, so the user input is shown in the 'not understood' message

  • Add a 'Go to' to link the Lookup Action block to 'Not understood'

You can also add the offloading message after the lookup, to make sure the user can get the answer from a human agent if the answer is not sufficient.

And that's it! You just created a more user-friendly 'not understood' message!

With Google Programmable Search you can include a search engine on a website you specified. We will use this (free) feature of Google for this tutorial. First, create a new search engine for your website. Simply add your website or the webpages where you want to search and click save.

For this tutorial, you need the and your search engine ID.

here
GoogleAPI key
An example of the 'Not understood' lookup functionality using the Chatlayer docs.