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 fullDateTime
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 fullDateTime
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 theday
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.