How to Get Started With Google Actions

Continued from page 2. 

We provide the name of the Intent as “Population in Age Group Intent”. Now in the User Says field, you can start typing in the conversations that you would expect your Agent to process. For e.g. type in “tell me the population of Sweden” or “I would like the population distribution for South Africa” and press Enter.

This will result in the form automatically parsing out the sentence and parameterizing your request text as shown below. Notice how it is able to map a country name to an in-built entity that API.AI provides i.e. sys.geo-country. Notice the column VALUE in which it indicates how you can access the value of the country i.e. $geo-country.

The important thing now is to specify that this is a mandatory piece of information that you expect from the user and if the user does not provide the information, then the Agent will continue to prompt for that information.

To do that, check the REQUIRED field as shown below and also provide a prompt text in the PROMPTS column. This text will be played back to the user if the information is not provided.

The next thing is to add another two parameters: year and age. Simply add them after the geo-country parameter. For the year parameter, use the name year and use one of the standard entity types made available by API.AI. Since it is a number that we are looking for, we have selected @sys.number-integer. Finally for the age group parameter, use the name age and the standard entity type @sys.number-integer. Provide prompts for the two additional variables as shown below:

Finally, we need to provide a Response if the request information is passed successfully. Since we are not integrating it with any backend system, we can spoof the response in the Text response field as shown below. Note how we used the $ prefix to refer to the VALUE field that was present in the parameters.

Save the Intent details. Now we can test out the Intent details in the right panel as shown below. For e.g. say “population of Mexico”. This will match to the Population in Age Group Intent.

Notice, how the response is correctly provided as the next piece of information that the Agent wants i.e.”Please provide the year to retrieve the population table for?”. We can then provide it the year.

We can continue the conversation by providing the last piece of information i.e. age group and it will give us the final response that we have set in the Intent, as shown below:

If you click on the Show JSON link, you can see the JSON data that would be sent as a request. Notice how the parameters year, geo-country and age are passed as request parameters in the JSON. This will help your backend implementation to extract out this information and then do the required processing to fulfill the request.

We have now been able to write an API.AI Agent that has been able to process our request in Natural Language and has returned us a dummy response. We did this to ensure that the Agent is correctly functioning.

Training Your Agent

One of the nice features of the API.AI platform is that you can train your Agent to get better by learning about new phrases and then trying to map them to a given Intent. This is the Training part of the Agent, currently available in Beta. It is accessible from the Training link in the main menu.

Be sure to read the next Machine Learning article: What are the Best Python Tools for Machine Learning?


Comments (4)


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)


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.




hey i am building a chatbot for aged care people can u please tell me which apis should i integerate in the dailogflow and how ??