How to Get Started With Google Actions

Continued from page 1. 

Our Agent will be able to engage in a conversation as follows:

User : Tell me about the population of Mexico ?
Agent : Please provide the year to retrieve the population table for?
User : The year is 2001
Agent : Please provide the age to retrieve the population table for?
User : I would like it for those who are 25 years old  
Agent : In 2001, the Population Statistics shows a total of 953,896 males and 1,005,427 females in Mexico in the age group of 25 years

If you notice in the above conversation, we have highlighted certain words in bold. These are keywords and parameters that will be understood by our Agent and then mapped to an Intent and eventual action i.e. retrieve the information about population statistics.

Additionally, we would like our agent to support natural language. What this means is that there could be variations in the way that people ask for information from the Population Statistics Agent. They could use statements like “Hi! Can you provide me information on the population in Hungary?” and it should still know that information on population is being requested because population is one of our keywords. Any statement including the ‘population’ keyword can map to the same intent.

Let’s see how we can build that using the API.AI platform.

Building our Action

What we are going to build is an Agent. Once you are logged into the API.AI platform, click on Create New Agent and fill out the form as shown below. We have provided the name WorldPopulationAgent for the Agent and left the other details with their default values. Click on Save.

This will bring you to the Intents page for the Agent that we created. You can see that there are two Intents that have been created by default.

The Default Welcome Intent is what is executed when the Agent is invoked on the device or application. Click on the Default Welcome Intent link and you will be presented with the details, of which, you will see a list of text messages that will be used to respond to the user. You will notice that there is a list of messages in the Response section. Go ahead and delete all of them. Now go ahead and add a welcome text response, an example of which is shown below. This will help identify your agent to the user. Remember to click on Save, when you do any of these changes.

Similarly, take a look at the Default Fallback Intent, which is invoked when you give a request that the Agent is not able to understand. Take a look at the list of messages provided, out of which one of them will be randomly returned. If required modify the list and click on Save.

Now, let us create a new Intent by clicking on the + sign in the Intents link in the main menu. This will bring up the new Intent form as shown below.

Our goal is to define a new Intent “Population in Age Group Intent” which will process what kind of information is requested by the user i.e. tell me the population in a particular age group categorized by male and female. We will also design a conversation dialog to ask the country name that the user wants the information for.

Romin Irani Romin loves learning about new technologies and teaching it to others. His passion is to help developers succeed.
 

Comments (3)

girishlal

I followed the tutorial and build the app. But in simulator I always get "Sorry, this action is not available in simulation”,any ideas you can suggest to resolve that? ( A.API and Simulator google account are same)

romin

I have faced this issue (occasionally) and have found it to be one of the following:

  1. A temporary problem with the service for testing that caused the problem.
  2. Multiple Google Accounts. I used to ensure that I was logged out then of all my accounts and logged in with the particular Google Account that I wanted to use.

Thanks,

Romin