Note: I am a Product Manager working on the Google Assistant and am very excited to see developers Start building Actions on Google.
But it is not just developers, everyone’s an expert at something and now you can share that expertise on Google Home with the Google Assistant and API.AI no coding required! Absolutely free and can take less than 1 hour.
There are three steps:
- Design the conversational experience
- Develop the Action in API.AI (remember, I promised, no coding required, you can do this!)
- Distribute the Action via the Google Actions Console
Let’s get started.
Check out the full docs at: https://developers.google.com/actions/develop/conversation
Step 1: Design
First decide what knowledge, passion or experience you can share with the world. Just a few ideas that work well for this format:
Cat facts, Uplifting quotes, Shakespearean insults, Parenting Tips, Lawyer Jokes, History facts, Lego facts, Inspirational Quote, Complement of day, Tax saving tips, Sounds of the ocean, Movie Quotes, Fortune teller, stock market prediction, celebrity gossip, Science facts, the sky is the limit…
The dialog format we will explore in this post is a “one shot” pattern. In the one shot pattern the end user talks to your action and you return immediately with exactly what the user needs. Of course API.AI supports much more than this, but let’s start simple shall we.
I’ll use something I know a bit about as our example: Douglas Adams’ Hitchhiker’s Guide to the Galaxy. The user asks for a random quote from the series of books and my Action returns one. So the dialog looks like:
Clearly this is a very simple flow. The user addresses their Google Home by saying “Ok Google, let me talk to Mostly Harmless Quotes”. Then the Google Assistant will introduce them to your Action. Each time the user talk to the this action, they will get a different quote.
Step 2: Develop
Go to https://api.ai/ , create an account and create the mostly harmless agent.
Now we need an intent. An intent maps what the user says to an action. By default we are given two intents:
Welcome Intent— will respond when our agent is invoked
Default Fallback Intent — will respond if a user says something that is not handled by any other intent
Next we need to give an example of what the user can say. We are going to temporarily add that explicitly in the user says line, later we will replace this with some specific Actions on Google integration.
Finally, we get to where we can enter our first quote way at the bottom this intent form after first deleting the default ones.
Now click save and test this in the test console on the right and give it a try. You can see that when the user says “talk to mostly harmless quotes” they get our answer. You can even click play to hear how it will sound.
Ok, add a few more examples. My suggestion is to give at least 10. These responses will be randomly given to the user, so chances are the user will get a different one each time.
Here is what my intent looks like after I add a few more quotes.
Bonus: Want to add some sound effects? It is very easy to do with SSML. You can read the full docs, but, here is an example of adding some cool sound effect at the end of the quote. You can also make the whole response be nothing more than playing a sound.
If you’d need help storing the sound files in a publicly access place, check out Google Cloud Storage.
Now we just need to get this intent ready to integrate with the Google Assistant. To do this go to the integrations tab and enable Actions on Google.
Then we fill out the actions on google metadata. We can start with just giving an invocation name (what the user will say to the google assistant to talk to this action) and setting the welcome-intent to be our only intent, conveniently named welcome-intent.
Now, one little fixup to do. way down at the bottom of the welcome intent, there is a check box to end the dialog after we say one of these expressions. (you may have to click on Actions on Google to show the option).
Now just authorize, go through the the permissions flow. Then click preview to see what this will be like in the Google Home.
At this point, if you have a Google Home signed in with the same Google Identity, you can simply say: “Ok Google talk to mostly harmless quotes” and you should hear one of your quotes!
You can also check out the web simulator.
At this point, it looks great! We should go ahead and publish it!
Step 3: Distribute
You have built a great Action, it is time to make sure the world can find it (at least the world of people with a Google Home).
Go to console.developers.google.com and create a new project
Give the project some meaningful name, notice the project ID is the most important to be readable, edit it to make something easy to type and remember. Also, notice we are prompted for a billing account. That is not needed. No charges apply for this walk through no matter how much traffic you get!
Once the project is created (takes about 1 min) you will see the big list of APIs. You are looking for the “Actions API”.
Then just click enable:
Switching over to the Directory listing tab shows this:
Now you just need to fill out this form. It is the way that end users will find your Action. So take a minute to make it look good. Here is what I came up with for my example.
Now we just need to publish our Action. Just grab that project ID
And paste that project ID into Google Project ID field in the API.AI project you created.
And click deploy! Now you are all set. Just wait for your Action to be reviewed and deployed. (it may take a few days).
Hope you had fun building an Action! Please drop me a line and tell me what you built.
Agent with ID ‘[project id]’ not registered
To address this:
- Verify that you have copied the project ID from the Developer Console exactly.
— or —
- Make sure the listing information is saved (not just entered) in directory listing. Ensure there are no errors when saving/registering. You should see the notice in the bottom left that “Directory listing saved”.