To develop for Actions on Google, you first need to create an Actions project and an API.AI agent. Having a project allows you to define metadata, manage your app through the approval process, view analytics for your app, and more. The API.AI agent defines intents that map what users say to the corresponding logic that fulfills the intent and responds back to the user.
- Download and unzip the Facts about Google sample app from GitHub
the repository. We'll refer to the sample app directory as
<sample_dir>. The sample app contains an API.AI agent (
<sample_dir>/FactsAboutGoogle.zip) and the corresponding fulfillment (
- Turn on Web & App Activity, Voice & Audio Activity, and Device Information permissions on the Activity controls page for your Google account. You need to do this to use the Actions Simulator, which lets you test your actions on the web without a hardware device.
- Create a project and agent:
- Go to the Actions on Google Developer Console.
- Click on Add Project, enter
FactsAppfor the project name, and click Create Project.
- In the Overview screen, click on Use API.AI and then CREATE ACTIONS ON API.AI to start building actions.
- The API.AI console appears with information automatically populated in an agent. Click Save to save the agent.
<sample_dir>/FactsAboutGoogle.zipinto the FactsApp agent:
- In the left navigation, click on the gear icon to the right of the agent name.
- Click on the Export and Import tab.
- Click RESTORE FROM ZIP and select the
RESTOREin the text box, click RESTORE, then DONE. When the restoration is finished, the following screen appears. Make note of your app's project ID; you'll need it to deploy the sample's fulfillment.
You now have an API.AI agent that includes intents that are triggered when users say specific phrases. You can learn more about the intents in the next section or move on to deploying fulfillment for the app as a Cloud Function for Firebase.
When the import is finished, you'll have an agent populated with the following intents:
Default Welcome Intent- This intent is the default intent that is triggered when users initially invoke your app. It responds with "Welcome to Facts about Google! Do you want to hear about Google's history or do you want to hear about its headquarters?"
choose_fact- This intent is triggered when users say they want to hear a history or headquarters fact about Google. It defines samples phrases and parameters in the User says phrases. Parameters tell API.AI to parse certain values from the user input so your fulfillment knows which fact to deliver. In this case, API.AI parses either
tell_fact- This intent is triggered when users say "Yes", "I want to hear another", or similar phrases when they want to hear another fact (either history or headquarters facts).
quit_facts- This intent triggers when users say "Bye", "I'm done now", or similar phrases.
- Cat facts easter egg - Facts about cats are also available and the
conversation is driven by the
tell_cat_factintents. These intents work similarly to