Join the Actions on Google Developer Challenge to win a trip to Google I/O 2018 and more than 20 other prizes.

Define Actions

To define actions in your action package, you create an intent that defines how the action is invoked and the corresponding fulfillment endpoint for when the intent is triggered. You can create the following types of actions:

  • Default action: If your app supports being invoked by name (for example "Ok, Google. Talk to Facts about Google" or "Ok, Google. Let me talk to Facts about Google"), then its action package must have one and only one action that's invoked when users ask for your app by name. This action declares support for the actions.intent.MAIN intent.

  • Additional actions to deep link into your app: These actions are triggered when users invoke your app by its name and specify an action phrase (for example "talk to Facts about Google for history facts").

See Invocation and Discovery for more information on how these invocation models work.

Define a default action

Every action package must have one and only one intent that handles the actions.intent.MAIN intent. This intent is triggered when users invoke by app name (for example, "Ok Google, talk to Facts about Google").

{
  "actions": [
   {
     "name": "MAIN",
     "fulfillment": {
       "conversationName": "factsAboutGoogle"
     },
     "intent": {
       "name": "actions.intent.MAIN"
     }
   }
  ],
  "conversations": {
   "factsAboutGoogle": {
     "name": "factsAboutGoogle",
     "url": "https://us-central1-factsapp-975bf.cloudfunctions.net/conversationComponent"
   }
  }
}

Define additional actions

You can provide additional actions that act as entry points into your app. This lets users disambiguate their intent by letting them specify more details about what they want to do (for example, "talk to Facts about Google to find me history facts").

To define additional actions:

  1. In the actions array, specify an action for every entry point into your app. For example:

    {
      "name": "FIND_FACT",
      "intent": {
        "name": "com.example.facts.FIND_FACT"
      },
      "fulfillment": {
        "conversationName": "factsAboutGoogle"
      }
    }
    
  2. Declare queryPatterns that trigger the action. For example, if you want users to be able to say "talk to Facts about Google to find me history facts", you'd declare an intent with query patterns like this:

    {
       "name": "FIND_FACT",
       "fulfillment": {
         "conversationName": "factsAboutGoogle"
       },
    
        "intent": {
          "name": "com.example.facts.FIND_FACT",
          "queryPatterns": [    
                {"queryPattern": "find me history facts"},
                {"queryPattern": "look up history facts"},
                {"queryPattern": "get me facts about history of the company" }
          ]
      }
    }
    
  3. Specify the fulfillment for this intent by specifying a conversationName for the intent that corresponds to an item in the conversations array.

    {
         "name": "FIND_FACT",
         "fulfillment": {
           "conversationName": "factsAboutGoogle"
    },
    
    ...
    
    "conversations": {
       "factsAboutGoogle": {
         "name": "factsAboutGoogle",
         "url": "https://us-central1-factsapp-975bf.cloudfunctions.net/conversationComponent"
       }
    }