Continued from page 4.
We can now take the ngrok forwarding address and since we have exposed a relative url /apiai, we provide the URL as shown below. Click on Save to confirm the changes.
Configuring the Intent Response
Once you have saved the above information, you should go back to your specific Intent and in the Fulfillment section, enable the Webhook invocation as part of the Action as shown below:
You can test out the Agent with the live Webhook integration via the same Test console that we saw earlier. If everything goes well, it should invoke your API, made available over ngrok and you should see the response in the Agent Test console. A sample run is shown below:
Google Home Integration
So far we have focused on writing our Agent and designing the conversational experience. At the end of the last section, we completed unit testing our action to a certain extent. Now that we have our Agent ready, the best part about the API.AI platform is how you can now make this Agent available across multiple platforms that it supports. This is done via its support for Integrations and it is available in the main menu.
From the main menu, simply click on Integrations and you will be presented multiple options for Integration. Our target in this article is making this Agent via Google Actions. All you need to do is toggle the “Actions on Google” button to “on” as shown below:
Toggling the button to “on” will enable Actions on Google and will bring up a dialog via which you can Preview and Deploy your Action. Let us first focus on Preview action, which also allows us to test the Action via the Google Home Simulator.
Testing our Action
As mentioned, toggling the “Actions on Google” integration to “on” will bring up the Authorize screen as shown below:
You will need to provide the Invocation name for testing, the value of which I have provided as PopulationStats. This will be the mechanism for activating the Agent on your Google Assistant, for example “Talk to PopulationStats”. As discussed earlier, this will kick-start the Welcome Intent, which will play out the Welcome message that we configured.
Once you click on Authorize and go through the authorization process via your account, a preview version of your Agent will be made available for testing. Click on Preview and once the process completes, you will be greeted with a message as shown below.
Click on the Google Home Web Simulator link in the message. This will bring you a Web Simulator where you can check your Google Action running on a simulated version of Google Home. This is a great feature and allows you to test the action without actually having the physical device.
Click on Start button and once authorization is done, you will be presented with the interface to our PopulationStats Agent. We can either type or use voice to give the command. For example when I say “Talk to PopulationStats”, it invokes the welcome intent and the welcome message that we configured is said, as shown below:
The next screen indicates the sample interaction that I have had and how it maps correctly to the Intents and displays the final result. Pretty neat, isn’t it?
So far we have been testing out our Action in the Preview mode. The preview mode is made available for a certain amount of time only. It is not publicly available to all users of the Google Home device. To publish your Agent, you will need to follow the distribution guide given here. It consists of creating a Google Cloud Project, enabling Actions API and then using the Google Cloud Project ID in the Publish dialog in the API.AI application. The publication process is similar to the ones that we have in mobile application stores, where it will be reviewed by Google before it is made public to all.
This article gave an overview of how we can use the API.AI platform to create a Google Action. Google Actions are currently available on Google Home only but it is expected that it will be rolled out to their other devices / applications that run the Google Assistant like Google Pixel Phone, Google Allo and others.