Types
Stay organized with collections
Save and categorize content based on your preferences.
Types let you configure the Assistant NLU (natural language understanding)
engine to extract structured data from user input. You
can use types in the following situations:
In intents, you can annotate training phrases with types to
create slots. When users say something that matches a slot, the NLU engine
extracts it as a typed parameter, so you can process it in a scene.
Within a scene's slot filling stage, you can specify
multiple slots that you want the user to provide before they can
transition or exit out of the scene.
Within a scene's conditions stage, you can base
logic on whether a parameter has a specific value that's defined in a type.
Custom types
Custom types let you create your own type specification to notify the NLU to
assign a set of values to a single key. You can specify types in a variety of
ways:
- Words and synonyms allow you to map multiple values to a single key,
which are called an entry. Your type can contain one or many entries. If you
choose this option, you can also enable the following NLU settings:
- Enable fuzzy matching - This feature allows entries with more than one
word to be matched, even when the words are spoken in a different order.
- Accept unknown values - When you can’t specify all possible values, the
language processor can accept unknown words or phrases based on surrounding
input and intent training data, such as items that might be added to a grocery
list.
- Regular expressions allows the type to match values using regular
expression patterns based on
Google's RE2 standard.
- Free form text allows the type to match
anything a user says. Annotating
an intent with this type lets you consume all input as a parameter that you
can pipe to your own NLU.
System types
System types let you annotate and extract well-known data from user input
using system-provided training data and values. The following system types are
supported:
Type |
Description |
actions.type.DateTime |
Contains date, time, and timezone based on the user's device settings.
Available for slot filling and training phrase annotation.
|
actions.type.Date |
Contains date only. Available for slot filling only. |
actions.type.Time |
Contains time only. Available for slot filling only. |
actions.type.Number |
The Number type matches ordinal and cardinal
numbers. |
DateTime
, Date
, and Time
usage
These types behave differently depending on where you use the type and the
user input that matches the type.
Using with intents
Annotating training phrases in intents supports only the DateTime
type. User
input doesn't need to match an entire DateTime
value. For example, if a user
provides only the year, the session parameter might look like this:
"date_time": {
"year": 2019
}
Using with slot filling
Slot filling supports DateTime
, Date
, and Time
.
- If the slot type is
DateTime
, the Assistant prompts the user until a full
value is provided.
- If the slot type is
Date
, the Assistant prompts the user until a date
value is provided. When collected, the parameter you receive is a full
DateTime
with the time set to 00:00.
- If the slot type is
Time
, the Assistant prompts the user until a time
value is provided. When collected, the parameter your receive is a full
DateTime
object with the date set to the current date.
For example, suppose a user in Los Angeles said, "Hey Google, create a reminder
for January 15, 2024 at 8 pm." When DateTime
is extracted as part of a slot
filling process, the full parameter might look like this:
"date_time": {
"day": 15,
"hours": 20,
"minutes": 0,
"month": 1,
"nanos": 0,
"seconds": 0,
"time_zone": {
"id": "America/Los_Angeles"
},
"year": 2024
}
Using with conditions
Conditions only allow the use of numbers and strings, so using the top level
DateTime
parameter results in a False result for the condition. For
example:
$session.params.my_dateTime.day > 5
is a valid condition, because the
day
value is a number and is supported.
$session.params.my_dateTime > "01-01-2010"
is an invalid condition, because
the top level 'DateTime' object is not a number or string.
Runtime type overrides
Runtime type overrides let you dynamically create or modify types in
fulfillment. This feature lets you add to or replace a type's specification at
runtime. For example, you can check a backend data source to load daily menu
items into a type in your fulfillment.
See the webhooks guide for more information
on how to build type overrides.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eTypes are used to extract structured data from user input, allowing you to create slots in intents, manage slot filling within scenes, and define conditions based on parameter values.\u003c/p\u003e\n"],["\u003cp\u003eYou can create custom types using words and synonyms, regular expressions, or free-form text to define how the NLU interprets user input.\u003c/p\u003e\n"],["\u003cp\u003eSystem types such as \u003ccode\u003eDateTime\u003c/code\u003e, \u003ccode\u003eDate\u003c/code\u003e, \u003ccode\u003eTime\u003c/code\u003e, and \u003ccode\u003eNumber\u003c/code\u003e provide built-in data extraction for common data formats.\u003c/p\u003e\n"],["\u003cp\u003eRuntime type overrides enable dynamic modification of types during fulfillment, allowing you to adjust types based on real-time data.\u003c/p\u003e\n"]]],[],null,["# Types let you configure the Assistant NLU (natural language understanding)\nengine to extract structured data from user input. You\ncan use types in the following situations:\n\n- In [intents](/assistant/conversational/intents), you can annotate training phrases with types to\n create slots. When users say something that matches a slot, the NLU engine\n extracts it as a typed parameter, so you can process it in a [scene](/assistant/conversational/scenes).\n\n- Within a scene's [slot filling](/assistant/conversational/scenes#slot_filling) stage, you can specify\n multiple slots that you want the user to provide before they can\n transition or exit out of the scene.\n\n- Within a scene's [conditions](/assistant/conversational/scenes#conditions) stage, you can base\n logic on whether a parameter has a specific value that's defined in a type.\n\nCustom types\n------------\n\nCustom types let you create your own type specification to notify the NLU to\nassign a set of values to a single key. You can specify types in a variety of\nways:\n\n- **Words and synonyms** allow you to map multiple values to a single key, which are called an entry. Your type can contain one or many entries. If you choose this option, you can also enable the following NLU settings:\n - **Enable fuzzy matching** - This feature allows entries with more than one word to be matched, even when the words are spoken in a different order.\n - **Accept unknown values** - When you can't specify all possible values, the language processor can accept unknown words or phrases based on surrounding input and intent training data, such as items that might be added to a grocery list.\n- **Regular expressions** allows the type to match values using regular expression patterns based on [Google's RE2 standard](https://github.com/google/re2/wiki/Syntax).\n- **Free form text** allows the type to match anything a user says. Annotating an intent with this type lets you consume all input as a parameter that you can pipe to your own NLU.\n\nSystem types\n------------\n\nSystem types let you annotate and extract well-known data from user input\nusing system-provided training data and values. The following system types are\nsupported:\n\n| Type | Description |\n|-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| **`actions.type.DateTime`** | Contains date, time, and timezone based on the user's device settings. Available for slot filling and training phrase annotation. |\n| **`actions.type.Date`** | Contains date only. Available for slot filling only. |\n| **`actions.type.Time`** | Contains time only. Available for slot filling only. |\n| **`actions.type.Number`** | The `Number` type matches ordinal and cardinal numbers. |\n\n### `DateTime`, `Date`, and `Time` usage\n\nThese types behave differently depending on where you use the type and the\nuser input that matches the type.\n\n#### Using with intents\n\nAnnotating training phrases in intents supports only the `DateTime` type. User\ninput doesn't need to match an entire `DateTime` value. For example, if a user\nprovides only the year, the session parameter might look like this: \n\n \"date_time\": {\n \"year\": 2019\n }\n\n#### Using with slot filling\n\nSlot filling supports `DateTime`, `Date`, and `Time`.\n\n- If the slot type is `DateTime`, the Assistant prompts the user until a full value is provided.\n- If the slot type is `Date`, the Assistant prompts the user until a date value is provided. When collected, the parameter you receive is a full `DateTime` with the time set to 00:00.\n- If the slot type is `Time`, the Assistant prompts the user until a time value is provided. When collected, the parameter your receive is a full `DateTime` object with the date set to the current date.\n\nFor example, suppose a user in Los Angeles said, \"Hey Google, create a reminder\nfor January 15, 2024 at 8 pm.\" When `DateTime` is extracted as part of a slot\nfilling process, the full parameter might look like this: \n\n \"date_time\": {\n \"day\": 15,\n \"hours\": 20,\n \"minutes\": 0,\n \"month\": 1,\n \"nanos\": 0,\n \"seconds\": 0,\n \"time_zone\": {\n \"id\": \"America/Los_Angeles\"\n },\n \"year\": 2024\n }\n\n#### Using with conditions\n\nConditions only allow the use of numbers and strings, so using the top level\n`DateTime` parameter results in a **False** result for the condition. For\nexample:\n\n- `$session.params.my_dateTime.day \u003e 5` is a valid condition, because the `day` value is a number and is supported.\n- `$session.params.my_dateTime \u003e \"01-01-2010\"` is an invalid condition, because the top level 'DateTime' object is not a number or string.\n\nRuntime type overrides\n----------------------\n\nRuntime type overrides let you dynamically create or modify types in\nfulfillment. This feature lets you add to or replace a type's specification at\nruntime. For example, you can check a backend data source to load daily menu\nitems into a type in your fulfillment.\n\nSee the [webhooks](/assistant/conversational/webhooks#runtime_type_overrides) guide for more information\non how to build type overrides."]]