Within the trend of IoT, Google Home is amongst the most popular. Thankfully, Google has made the development of actions quite approachable. To get an overview of the process, let’s create a weather integration together.

Actions on Google

Creating your Google Home integration starts with Actions on Google (AoG). Quoting Google:

Actions on Google is the platform for developers to extend the Google Assistant. Join this emerging ecosystem by developing actions to engage users on Google Home, Pixel, and many other surfaces where the Google Assistant will be available.

Now, it’s time to create your action. Under the Build section, click ADD ACTION and finally select Custom intent. After creating the action, Google will redirect you to their Dialogflow service.

Dialogflow

Dialogflow is Google’s intuitive natural language processing (NLP) tool. Here is where you train the AI to recognize intents. This is by far the smoothest part of creating a Google Home integration. Create an intent and just type in a few example phrases to train the AI.

  • How’s the weather today?
  • What’s the weather?
  • How’s the weather in Copenhagen?

After configuring the training phrases, make sure to check the box Enable webhook call for this intent. Doing so allows you to add fulfillments programmatically.

Fulfillment

A fulfillment is a response to an intent. Programmatic fulfillments allow you to do many things: present a card with information, prompt a user for more information or show an error. Fulfillments use the webhook REST API and can be served through cloud functions or self hosting.

Cloud Functions

In the Fulfillment tab on Dialogflow you have the option to edit a fulfillment and deploy it to Google Cloud Functions all within the inline editor. If you’re short on time or your project isn’t that large, this is by far the simpler option of the two.

Self-hosting

If you’re working on a larger project or cloud functions aren’t your thing, you can host your server and configure Dialogflow to fulfill all requests using your server. As most major programming languages have a fulfillment library, you have a much wider choice in what to develop your fulfillment in.

Testing

After developing and deploying your fulfillment, it’s time to test. On the Dialogflow website, go to the Integrations section and then click on INTEGRATION SETTINGS. At the bottom of the dialog, you should see the button TEST. If clicking the button gives you the error there was an error completing your request make sure Google selected the correct user in the upper-right corner.

You should now be in the Simulator where you can test all of your actions and intents. As a bonus, all supported Google devices linked to the same email will be able to test your actions.

Try it out!

Ok Google, ask My Test App about the weather

Conclusion

Creating a Google Home integration and fulfillment is an intuitive and relatively easy process. There is some friction with the integration between the different Google services, but overall everything works nicely.

Key takeaways

  • Setting up a Google Action is very easy
  • Intents have to be trained manually for every single language your application supports
  • Localization of fulfillments will take a bit of effort
  • NodesJS and Go seem to be the most supported languages
  • You can only address your app explicitly. Ex. “Okay Google, ask … about the weather”
server google home ai api cloud serverless

Author

Brett R. Toomey

Vapor & iOS Developer

Using Swift to take over the world.

You may also like

A dive into the Observer Pattern in iOS applications

Often when developing iOS applications with more complex requirements we may encounter the need to react to, and perform UI updates on, not so easily accessible UI components. Another example could be that we must update an object outside our currently focused scene, perhaps created by a scene a few...

iOS
Bugsnag for Vapor 3

At Nodes we have been working hard on a Vapor 3 provider for Bugsnag. Bugsnag is a reporting tool that we use extensively to help catch and fix bugs.

Vapor