Create shortcuts.xml

Once you identify your in-app functionality and corresponding built-in intent (BII) to implement, declare the BIIs your functionality supports by defining a capability element in a shortcuts.xml resource file. Declaring a BII as a capability registers support for that semantic intent in your app, and enables voice query fulfillment of the intent using Google Assistant.

Assistant uses natural language processing to extract parameters from a user query. The built-in intents reference lists the fields that each BII is capable of extracting from an associated user query. For example, if a user invokes the [actions.intent.GET_FOOD_OBSERVATION][] capability in your app by saying, "Hey Google, Ask ExampleApp what did I eat for Lunch last Friday", Assistant extracts the following BII parameters from the user request:

  • foodObservation.forMeal = "https://schema.googleapis.com/MealTypeLunch"
  • foodObservation.startTime = "2024-09-06T00:00:00"
  • foodObservation.endTime = "2024-09-06T23:59:59"

Assistant passes BII parameters to the fulfillment intent defined in the capability. One or more intent elements can be defined in a capability to accommodate the different ways a user might invoke a BII. For instance, you could define a fulfillment intent that requires both BII parameters in the above example. You could then define a second intent that requires a single BII parameter, foodObservation.forMeal, that reports for all meals on a particular day, like "Hey Google, Ask ExampleApp what did I eat for Lunch."

Overview

You configure App Actions using a shortcuts.xml file placed in your app project's res/xml directory, and then creating a reference to shortcuts.xml in your app manifest. Add a reference to shortcuts.xml in your app manifest by following these steps:

  1. In your app's manifest file (AndroidManifest.xml), find an activity whose intent filters are set to the android.intent.action.MAIN action and the android.intent.category.LAUNCHER category.