- Action ID
actions.intent.GET_FOOD_OBSERVATION
- Description
-
Present the calculated or observed value for a property of a nutrient the user has consumed.
We recommend that you specify entities for
foodObservation.aboutNutrient.name
.This built-in intent uses enumerated values for some parameters. Parameters that follow this pattern are listed in Supported text field values below, with the enumerated parameter values they support.
Locale support
Functionality | Locales |
---|---|
Preview creation using App Actions test tool | en-US, en-GB, en-CA, en-IN, en-BE, en-SG, en-AU |
User invocation from Google Assistant | en-US, en-GB, en-CA, en-IN, en-BE, en-SG, en-AU |
Example queries
Recommended fields
The following fields represent essential information that users often provide in queries that trigger this built-in intent:
foodObservation.aboutNutrient.name
foodObservation.disambiguatingDescription
Other supported fields
The following fields represent information that users often provide to disambiguate their needs or otherwise improve their results:
foodObservation.@type
foodObservation.aboutNutrient.@type
foodObservation.endTime
foodObservation.forMeal
foodObservation.startTime
Android widgets and slices
We recommend implementing Android widgets for this built-in intent. A widget presents information or interaction options from your app to improve user engagement in Google Assistant. Widgets are available for App Actions implementations using shortcuts.xml.
If you have a legacy App Actions implementation using
actions.xml, use
Android slices instead. We recommend
migrating your
implementation to shortcuts.xml
to take advantage of widgets
fulfillment and other improvements.
Supported text values by field
Inventory availability by field
Sample XML files
For information about the shortcuts.xml
schema, see Create shortcuts.xml.
Handle BII parameters
shortcuts.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample shortcuts.xml -->
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<capability android:name="actions.intent.GET_FOOD_OBSERVATION">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="YOUR_UNIQUE_APPLICATION_ID"
android:targetClass="YOUR_TARGET_CLASS">
<!-- Eg. endTime = "2011-12-27T23:59:59" -->
<parameter
android:name="foodObservation.endTime"
android:key="endTime"/>
<!-- Eg. forMeal = "http://schema.googleapis.com/MealTypeLunch" -->
<parameter
android:name="foodObservation.forMeal"
android:key="forMeal"/>
<!-- Eg. startTime = "2011-12-27T00:00:00" -->
<parameter
android:name="foodObservation.startTime"
android:key="startTime"/>
<!-- Eg. name = "Calories" -->
<parameter
android:name="foodObservation.aboutNutrient.name"
android:key="name"/>
</intent>
</capability>
</shortcuts>
actions.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.GET_FOOD_OBSERVATION">
<fulfillment urlTemplate="myapp://custom-deeplink{?endTime,forMeal,startTime,name}">
<!-- e.g. endTime = "2011-12-27T23:59:59" -->
<!-- (Optional) Require a field eg.endTime for fulfillment with required="true" -->
<parameter-mapping urlParameter="endTime" intentParameter="foodObservation.endTime" required="true" />
<!-- e.g. forMeal = "http://schema.googleapis.com/MealTypeLunch" -->
<parameter-mapping urlParameter="forMeal" intentParameter="foodObservation.forMeal" />
<!-- e.g. startTime = "2011-12-27T00:00:00" -->
<parameter-mapping urlParameter="startTime" intentParameter="foodObservation.startTime" />
<!-- e.g. name = "Calories" -->
<parameter-mapping urlParameter="name" intentParameter="foodObservation.aboutNutrient.name" />
</fulfillment>
<!-- Provide a fallback fulfillment with no required parameters. For example, to your app search or router deeplink -->
<fulfillment urlTemplate="myapp://deeplink" />
</action>
</actions>
Use inline inventory
shortcuts.xml
foodObservation.aboutNutrient.name
is an
intent parameter that supports inline inventory.
By defining a <shortcut>
for foodObservation.aboutNutrient.name
,
you can uniquely identify entities that are of interest to your app or restrict
fulfillment to the set of supported entities.
In the following example, when the user query matches the
name_one
shortcut, Assistant provides the associated shorcut identifier, ID_ONE
, as
the URL parameter name
to fulfillment.
If there is no inventory match, the text value received in the query for
foodObservation.aboutNutrient.name
is passed
as-is.
<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample shortcuts.xml -->
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<capability android:name="actions.intent.GET_FOOD_OBSERVATION">
<intent
android:targetPackage="YOUR_UNIQUE_APPLICATION_ID"
android:targetClass="YOUR_TARGET_CLASS">
<parameter
android:name="foodObservation.endTime"
android:key="endTime"/>
<parameter
android:name="foodObservation.forMeal"
android:key="forMeal"/>
<parameter
android:name="foodObservation.startTime"
android:key="startTime"/>
<parameter
android:name="foodObservation.aboutNutrient.name"
android:key="name"/>
</intent>
</capability>
<!-- Short and long labels must be @string resource. -->
<shortcut
android:shortcutId="ID_ONE"
android:shortcutShortLabel="@string/shortcut_short_label"
android:shortcutLongLabel="@string/shortcut_long_label">
<capability-binding android:key="actions.intent.GET_FOOD_OBSERVATION">
<parameter-binding
android:value="name"
android:key="foodObservation.aboutNutrient.name"/>
</capability-binding>
</shortcut>
</shortcuts>
actions.xml
foodObservation.aboutNutrient.name
is an
intent parameter that supports inline inventory.
By defining an <entity-set>
for foodObservation.aboutNutrient.name
,
you can uniquely identify entities that are of interest to your app or restrict
fulfillment to the set of supported entities.
In the following example, when the user query matches the
name_one
entity, Assistant provides the associated identifier, ID_ONE
, as
the URL parameter name
to fulfillment.
If there is no inventory match, the text value received in the query for
foodObservation.aboutNutrient.name
is passed
as-is.
<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.GET_FOOD_OBSERVATION">
<fulfillment urlTemplate="myapp://deeplink{?name}" >
<!-- name = "ID_ONE" or "ID_TWO" -->
<!-- If no inventory match, name is a text value, such as "Calories" -->
<!-- (Optional) Use entityMatchRequired="true" to require inventory match for fulfillment -->
<parameter-mapping urlParameter="name" intentParameter="foodObservation.aboutNutrient.name" />
</fulfillment>
<!-- Define parameters with inventories here -->
<parameter name="foodObservation.aboutNutrient.name">
<entity-set-reference entitySetId="nameEntitySet"/>
</parameter>
</action>
<entity-set entitySetId="nameEntitySet">
<!-- Provide an identifier per entity -->
<entity identifier="ID_ONE" name="name_one" alternateName="@array/name_one_synonyms"/>
<entity identifier="ID_TWO" name="name_two" alternateName="@array/name_two_synonyms"/>
</entity-set>
</actions>
The url
attribute associated with the entity can be used to
determine the fulfillment URL if there is an inventory match. In the following
example, when the user query matches the
name_one
entity, Assistant provides myapp://deeplink/one
as the fulfillment
URL.
<?xml version="1.0" encoding="utf-8"?>
<!-- This is a sample actions.xml -->
<actions>
<action intentName="actions.intent.GET_FOOD_OBSERVATION">
<!-- Use url from inventory match for deep link fulfillment -->
<fulfillment urlTemplate="{@url}" />
<!-- Provide a fallback fulfillment with no required parameters. For example, to your app search or router deeplink -->
<fulfillment urlTemplate="myapp://deeplink" />
<!-- Define parameters with inventories here -->
<parameter name="foodObservation.aboutNutrient.name">
<entity-set-reference entitySetId="nameEntitySet"/>
</parameter>
</action>
<entity-set entitySetId="nameEntitySet">
<!-- Provide a URL per entity -->
<entity url="myapp://deeplink/one" name="name_one" alternateName="@array/name_one_synonyms"/>
<entity url="myapp://deeplink/two" name="name_two" alternateName="@array/name_two_synonyms"/>
</entity-set>
</actions>
JSON-LD sample
The following JSON-LD sample provides some example values that you can use in the App Actions test tool:
{ "@context": "http://schema.googleapis.com", "@type": "FoodObservation", "aboutNutrient": { "@type": "Nutrient", "name": "Calories" }, "disambiguationDescription": "CONSUMED", "endTime": "2011-12-27T23:59:59", "forMeal": "http://schema.googleapis.com/MealTypeLunch", "startTime": "2011-12-27T00:00:00" }