Get started

This guide walks you through developing and testing App Actions in your app.

Before you begin

Make sure you have installed the latest version of Android Studio.

To test App Actions, you must use a physical Android device. The recommended OS version is Android 8 (API level 26) or higher, although Actions run on devices back to Android 5 (API level 21).

Additional requirements:

  • Before testing with a physical device, connect it to your local development machine.
  • Your test device needs access to the Play Store to update the Google app.
  • You must be logged in to the Google app on the device and logged in to Android Studio using the same Google account.
  • Ensure all apps are up-to-date from the Google Play Store (verify Google Play Services and the Google app in particular).
  • Set up and test that the Assistant is working by long-pressing on the Home button.

We also strongly encourage you to download and try the App Actions fitness sample on GitHub.

Start by choosing which Activities in your Android app make sense to be accessed via App Actions. Review the available App Action built-in intent definitions for your app category and try matching these built-in intents with key functionality or user flows in your app.

App Actions start Android Activities via deep links that the Assistant generates. The deep link can be based on App Links URLs, Intent-based URLs, or custom schemes (for example: myapp://do.thing/foo=bar).

To test that your Activities are accessible and that they can be triggered using App Actions, run the following adb command:

$ adb shell am start -a android.intent.action.VIEW -d "[App Links URL]"

For example:

$ adb shell am start -a android.intent.action.VIEW -d ""

If your Activity does not launch correctly with the adb command, then check the following:

  • If using App Links URLs, ensure you have followed all the steps in Handling Android App Links.
  • Ensure exported=true is set on the Activity.

2. Create the actions.xml file

Create a new actions.xml file in your res/xml directory.

Here's an example of what the actions.xml file could contain for an Action that gets fulfilled using an App Links URL:

    <action intentName="actions.intent.CREATE_TAXI_RESERVATION">
        <fulfillment urlTemplate="{?dropoffAddress}">
            <!-- Dropoff location as an address -->

See the actions.xml documentation for additional details on configuring your actions.xml.

Once created, reference your actions.xml file from your AndroidManifest.xml file using a <meta-data> tag:

<meta-data android:name="" android:resource="@xml/actions" />

Optional: Specify your inline inventory

Inline inventory is a lightweight way to optionally specify parameter values your app expects inside your actions.xml.

This feature is useful if your app has a finite list of possible values it already understands, such as identifiers for different restaurant menu items or different types of financial accounts. When the user invokes your App Actions, the Assistant maps their query parameters to your specified inline inventory, generates the deep link URL accordingly, and sends these identifiers to your app.

For example, if your app offers different beverages that users can order, users might make requests like this for the same type of beverage:

  • "Hey Google, order a Blueberry Crisp Iced Signature Latte from CoffeeTime app"
  • "Hey Google, order a Blueberry Iced Coffee from CoffeeTime app"

If you specified a unique ID for this beverage (for example, "12345a") in your inline inventory, the Assistant internally converts the user's given string input to the ID and passes this to your app.

You can define inline inventory in your actions.xml by using <entity-set> tags to specify inventory for values associated with parameter types. To see an example, refer to this code snippet.

To learn more about configuring inline inventory, see Inline inventory for App Actions.

3. Preview your App Actions

You can use the App Actions test tool to test that App Actions work for your app. The plugin requires that you have at least one Android module available and exactly one Android module has an actions.xml file. The plugin is supported on Android Studio 3.4 and higher.

If your app is not yet published, create a draft in the Google Play console. To create a draft for your app, build your APK and upload it through the Play console. If your app is published, make sure that the Google account you are using has access to the app in the Google Play console.

Install the plugin

To install the plugin in Android Studio:

  1. Go to Settings > Plugins and search for "App Actions test tool" in the marketplace search box.
  2. Click the Install button and restart Android Studio. The plugin should now be available in the tools menu.

You can also download the plugin directly from the [Jetbrains public repository][].

Figure 1. The App Actions test tool plugin in Android Studio

Running the test tool

To use the App Actions test tool, follow these steps:

  1. Build and install the APK on your test device.
  2. In Android Studio, launch the test tool by selecting Tools > App Actions Test Tool.
  3. Click Authenticate and log in to a Google account that has access to your app's package name in the Play console. Make sure that your app is at least in draft mode in the Play console (the draft app does not have to be published).
  4. Log in with the same account to the Assistant on your test device.
  5. Once logged in, click Create Preview or Update Preview. This step posts your actions.xml file to the Google backend, which then fetches registered App Actions for your app (which should match what you have defined in your actions.xml).
  6. Select the built-in intent that you want to test from the dropdown menu. You can modify the default parameter values as required for testing, or delete field content that is not relevant. Use parameters that correspond to those you specified in the actions.xml file.

    See the built-in intent reference for the full list of built-in intents, their parameters, and example queries you can use for testing.

    For a nested field, you must specify its value in the JSON format that represents the structure of its higher level parameter as labeled. (The plugin's default query value for the labeled parameter shows an example of this expected format.)

  7. Select the device to run on. Click Run to trigger the Assistant with your specified configuration on your test device. Alternatively, click Copy to copy the adb command to run it from your development machine's terminal. When successful, the Assistant starts your app's activity.

    While previewing your App Action, you can also trigger queries by voice on the device itself while logged in to the Assistant with your developer account. This functionality is only available for queries listed in the built-in intents reference for App Actions. We recommend that you use voice triggering only for demonstration purposes rather than for regular testing.

  8. If you subsequently change your actions.xml file, your preview will not change on its own. You must click Create Preview or Update Preview again to update the Google backend.

For more detailed information about installing and using the test tool, see App Actions test tool.

4. Fulfill additional App Actions requirements

To ensure that users enjoy a seamless experience when using App Actions, you must fulfill the following requirements before your App Actions can be deployed:

  • Report App Action interaction results: To help Google proactively suggest your App Actions to users, use the Firebase App Indexing API to let the Assistant know whether your app has successfully handled a built-in request.
  • Handle the ACTION_SEARCH Android intent: To provide a fallback mechanism if Google is unable to resolve the user's query to a built-in intent, your app must support the ACTION_SEARCH common intent (required if your app already has a search capability).

For more detailed information, see App Actions deployment requirements.

5. Deploy your App Actions

To deploy your App Actions, follow these steps:

  1. Fill out the deployment request form.
  2. Wait to receive an email from Google indicating the status of your request (approved/rejected/waitlisted).
  3. If approved, you may deploy your app with actions.xml to Google Play. Subsequent app deployments are automatically deployed for serving.
  4. If approved, sign the Actions on Google Terms of Service in the Play console by going to Store presence > Pricing & distribution, then scrolling down to the Consent section. Once you've done this, upload your app with the actions.xml to the Play console.
Figure 2. Actions on Google Terms of Service in the Play console

After you deploy your app, your actions.xml will be reviewed by Google. Note that even if your app submission is approved, your actions.xml may still be under review by Google.

Your App Actions are only eligible for user triggering once your actions.xml is approved by Google. When you subsequently deploy your app, App Actions stay activated. However, redeployed versions are subject to review by Google. If the new version is broken or contains policy violations, Google reserves the right to deactivate App Actions for your app.