Learn how to use the Google Custom Search action inside your bot to answer each of your users’ queries and enrich your fallbacks.
This action’s mission is to make a research on a previously set domain or web site, from your users’ query, and displays its answers with Cards.
To learn how to create your Google Custom Search engine, please refer to this link: https://support.google.com/customsearch
🚨🚨 Be careful, Google Cusom Search is a paying service. Check out the pricing page before using it. 🚨🚨
1. Google Custom Search action
The Google Custom Search action is accessible from the action panel of every step. In order to use it, you must click on “Integrations” and then drag and drop “Google Custom Search” inside the step panel.
As you drag and drop the action, the “Configure Google Custom Search” window opens.
2. Google Custom Search configuration
The configuration panel includes several fields:
Google API Key: JSON Custom Search API requires the use of an API key. To get the key, start by creating your Custom Search Engine. Then, you will find the Google API Key at this page:
https://developers.google.com/custom-search/json-api/v1/overview
- Find this section and clic on « GET A KEY »
- Select the Custom Search Engine you’ve just created
- Then an Enable Custom API key is generated
- Copy the key and past it in your Google Custom Search API configuration
Search Engine ID (AKA CCX or CSE ID): you may go on this page to configure your own search engine.
https://support.google.com/customsearch/answer/2649143?hl=en
Here, enter the domain or website your search engine has to be connected with, define the language and give your engine a name to find it easily.
Once you’re here, the “Configuration” panel opens. At the “details” section, clic on the “search engine id” to copy your engine’s ID:
Then paste this ID inside the Google Custom Search panel:
Search Request: place here the syntax {{@message}}. This sends your user’s last message as a request to search by your custom search engine. But you can also insert any other entities, keywords or session value.
Scroll down the window and define how many cards you want your Google Custom Search to show:
3. Google Custom Search uses
Once you completed all the fields, click on “Confirm“. The action appears in the step panel.
As a result, as soon as your user enters a request and triggers your Google Custom Search story, his message will be sent as a search request by your search engine on the domain or web site you’ve defined, and will appear as Cards as a result for his query, inside the scenario created to bring answer to your user:
4. Build your conversation
- Create a Google Custom Search story
Create your scenario. The first question is to ask the user what he wants to search:
Then, go to the “links to” tab, click on “add a connection”, set the “User response” as “Is set” and create a link to your Google Custom Search step:
Then, on the next step named “Do a Google Search”, your Google Custom Search action will use the message of your user (the {{@message}}) as a request sent to your Custom Search Engine you’ve previously created!
- Include the Google Custom Search in your fallback
When your bot doesn’t understand the question, it sends the fallback answer. To go further than a basic fallback answer, you can customize your fallback for your bot to bring an answer even if it doesn’t understand!
You can include it in your step’s fallback to locally make a search in a specific step of your bot:
You can also include it as an answer directly into your general fallback, for every non-matched request of your users to trigger a reaserch on your previously set domain or web site:
Here you’re done with the basics steps to use this cool feature.
Are you ready to use it?
If you need more help, don’t hesitate to contact us!