Join us at Google I/O from May 18 to 20 for discussions, learning, and a first look at our latest developer products. Register now.

Custom intents

Every app is different, and not all app functionality matches an available App Actions built-in intent. For cases where there isn't a built-in intent (BII) for your app functionality, you can instead use a custom intent to extend your app with App Actions.

Like BIIs, custom intents follow the actions.xml schema and act as connection points between Assistant and your defined fulfillments. Custom intents also have intent parameters, which you can map to parameters in your corresponding fulfillment.

Unlike BIIs, custom intents require query patterns to describe example queries that a user might say. This approach differs from built-in intents, which each model common ways that users express that intent.


Custom intents have the following limitations:

  • The name of a custom intent must not begin with "actions.intent".
  • The name of a custom intent must be unique among custom intent names for your app.
  • Only certain data types are available for parameter extraction by Google Assistant. See Supported types for the list of supported types.
  • A maximum of two text parameters are supported per query. This limit does not apply to other data types.
  • Only the en-US locale is supported for custom intents (device and Assistant language settings must both match).

Supported types

Custom intents support the following types for parameter extraction:


Defining App Actions with custom intents

As with other App Actions that use built-in intents, you define a custom intent in the <action> element in actions.xml. Provide the name of the custom intent in the intentName attribute, and reference a query patterns resource file in the queryPatterns attribute:

<action intentName="custom.actions.intent.EXAMPLE_INTENT" queryPatterns="@array/ExampleQueries">
    <!-- Define parameters -->
    <!-- Define fulfillment -->

We recommend naming your custom intents using the prefix "custom.actions.intent" to distinguish them from both built-in intents and Android intents (which function differently). Custom intent names must not begin with "actions.intent", because that namespace is reserved for built-in intents.

For each parameter, provide the supported type that best describes the meaning of the parameter. For example, you can use to describe a number you expect to receive:

<action intentName="custom.actions.intent.EXAMPLE_INTENT" queryPatterns="@array/ExampleQueries">
    <parameter name="number1" type="" />
    <parameter name="text1" type="" />

    <!-- Define fulfillment -->

Fulfillment definition in actions.xml uses the same format with custom intents as it does with built-in intents. The following code describes an App Action that uses the referenced query patterns to trigger the "EXAMPLE_INTENT" custom intent and its corresponding fulfillment:

<action intentName="custom.actions.intent.EXAMPLE_INTENT" queryPatterns="@array/ExampleQueries">
    <parameter name="number1" type="" />
    <parameter name="text1" type="" />

    <fulfillment urlTemplate="{?number_of_items,item_name}">
        <parameter-mapping intentParameter="number1" urlParameter="number_of_items" />
        <parameter-mapping intentParameter="text1" urlParameter="item_name" />

Custom intent parameters can be configured with an inline inventory, which you can use to guide entity extraction to a set of supported entities specified in actions.xml.

The following code describes an App Action that defines an entity-set-reference for the "apptType" parameter, referencing an entity-set of eligible values for fulfillment:

<action intentName="custom.actions.intent.SCHEDULE_APPOINTMENT" queryPatterns="@array/scheduleApptQueries">
  <parameter name="date" type="" />
  <parameter name="time" type="" />
  <parameter name="apptType">
    <entity-set-reference entitySetId="ApptTypeEntitySet" />
  <fulfillment urlTemplate="{?apptType,date,time}">
    <parameter-mapping intentParameter="date" urlParameter="date" />
    <parameter-mapping intentParameter="time" urlParameter="time" />
    <parameter-mapping intentParameter="apptType" urlParameter="apptType" />
<entity-set entitySetId="ApptTypeEntitySet">
  <entity identifier="DRIVERS_LICENSE" name="@string/driversLicense" alternateName="@array/driversLicenseSynonyms" />
  <entity identifier="VEHICLE_REGISTRATION" name="@string/vehicleRegistration" alternateName="@array/vehicleRegistrationSynonyms" />

Query patterns

Each custom intent you use requires a set of queries expected from the user for that intent. This approach is unlike built-in intents, where queries are already modeled for common ways that users express tasks they're trying to do or information they seek.

In an Android resource file (usually /res/values/strings.xml), specify query patterns as items in a string array. When your App Action is invoked, Google Assistant checks the user query against your query patterns as part of matching the user's intent for fulfillment. Each query pattern you provide represents a phrase that you consider valid for the corresponding custom intent.

When providing query patterns for custom intents, expect each pattern to follow an explicit invocation like "open ExampleApp and" or "start ExampleApp and". For example, consider the following user queries:

  • "Hey Google, open ExampleGameApp and start making a cake."
  • "Hey Google, open ExampleGameApp and start making an apple pie."
  • "Hey Google, start ExampleGameApp and craft 5 cake items."
  • "Hey Google, use ExampleGameApp to produce cake 5 times."

To match user queries, provide query patterns that contain the portion of the query after the invocation phrase. For information you want to extract from the query (like text or a number provided by the user), you assign values to the corresponding intent parameter with placeholders in the query pattern.

From the custom intent's <parameter> element, take the value of the name attribute, prefix it with $, and use the prefixed value in your query patterns. For the actions.xml file created above in Defining App Actions with custom intents, the number1 and text1 intent parameters correspond to the query pattern placeholders $number1 and $text1, respectively.

The following code describes query patterns that match the above user queries and extract values for item names and the number of items to be made:

  <string-array name="ExampleQueries">
    <item>start making a $text1</item>
    <item>start making an $text1</item>
    <item>craft $number1 $text1 items</item>
    <item>produce $text1 $number1 times</item>

Query patterns support Conditionals. For example, "set (an)? appointment $date $time". In this case both "set appointment today at noon" and "set an appointment today at noon" are valid queries.