Typy
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Typy umożliwiają skonfigurowanie Asystenta NLU (rozumienia języka naturalnego)
do wyodrębniania uporządkowanych danych z danych wejściowych użytkownika. Ty
typów danych można używać w następujących sytuacjach:
W intentach możesz opisywać wyrażenia na potrzeby trenowania za pomocą typów, aby:
tworzyć przedziały. Gdy użytkownik powie coś, co pasuje do boksu, mechanizm NLU
wyodrębnia go jako typowy parametr, dzięki czemu można go przetworzyć w scene.
Na etapie wypełniania boksu w scenie możesz określić
wiele przedziałów, które użytkownik ma udostępnić, zanim będzie mógł
przejście lub wyjście poza scenę.
Na etapie warunków sceny możesz podstaw
logika określająca, czy parametr ma konkretną wartość zdefiniowaną w typie.
Typy niestandardowe
Typy niestandardowe pozwalają utworzyć własną specyfikację typu do powiadomienia NLU
przypisać zbiór wartości do jednego klucza; Możesz określić różne typy
sposoby:
- Słowa i synonimy pozwalają zmapować wiele wartości na jeden klucz,
nazywamy wpisem. Typ może zawierać jeden lub wiele wpisów. Jeśli
wybierz tę opcję, możesz też włączyć te ustawienia NLU:
- Włącz dopasowanie przybliżone – ta funkcja umożliwia wpisy z więcej niż jednym
dopasowane słowo, nawet jeśli słowa są wypowiadane w innej kolejności.
- Akceptuj nieznane wartości – jeśli nie możesz określić wszystkich możliwych wartości, komponent
procesor języka może akceptować nieznane słowa lub wyrażenia na podstawie otoczenia
dane wejściowe i trenowanie zamiarów, takie jak produkty, które można dodać do sklepu spożywczego
z listy.
- Wyrażenia regularne pozwalają typowi dopasować wartości za pomocą funkcji regularnych.
wzorów wyrażenia na podstawie
standard Google RE2.
- Tekst swobodny umożliwia dopasowanie typu.
ze wszystkim,
co mówi użytkownik. Dodaje adnotacje
intencja tego typu pozwala przetwarzać wszystkie dane wejściowe jako parametr,
możesz przesyłać fajki do własnej NLU.
Typy systemów
Typy systemów umożliwiają dodawanie adnotacji do dobrze znanych danych i wyodrębnianie ich z danych wejściowych użytkownika
na podstawie dostarczonych przez system danych i wartości treningowych. Następujące typy systemów są
obsługiwane:
Typ |
Opis |
actions.type.DateTime |
Zawiera datę, godzinę i strefę czasową na podstawie ustawień urządzenia użytkownika.
Dostępne w przypadku wypełniania przedziałów i adnotacji do wyrażenia treningowego.
|
actions.type.Date |
Zawiera tylko datę. Funkcja dostępna tylko do wypełniania przedziałów. |
actions.type.Time |
Zawiera tylko czas. Funkcja dostępna tylko do wypełniania przedziałów. |
actions.type.Number |
Typ Number pasuje do liczb porządkowych i kardynalnych
liczby. |
Użycie usług DateTime
, Date
i Time
Działanie tych typów zależy od miejsca użycia typu i
danych wejściowych użytkownika pasujących do typu.
Używanie z intencjami
Dodawanie adnotacji do wyrażeń treningowych w intencjach obsługuje tylko typ DateTime
. Użytkownik
dane wejściowe nie muszą odpowiadać całej wartości DateTime
. Jeśli na przykład użytkownik
podaje tylko rok, parametr sesji może wyglądać tak:
"date_time": {
"year": 2019
}
Użycie z wypełnianiem przedziałów
Wypełnianie przedziałów obsługuje DateTime
, Date
i Time
.
- Jeśli typ przedziału to
DateTime
, Asystent będzie prosić użytkownika o to, aż zostanie pełna
jest podana.
- Jeśli typ przedziału to
Date
, Asystent poprosi użytkownika o podanie daty
jest podana. Po zebraniu otrzymasz parametr z pełnym
DateTime
z godziną ustawioną na 00:00.
- Jeśli typ przedziału to
Time
, Asystent prosi użytkownika do
jest podana. Po zebraniu parametr odbierany sygnał będzie miał pełną
DateTime
obiekt z datą ustawioną na bieżącą.
Załóżmy na przykład, że użytkownik w Los Angeles powiedział: „OK Google, utwórz przypomnienie
15 stycznia 2024 r. o 20:00”. Gdy pole DateTime
jest wyodrębniane jako część przedziału
pełny parametr może wyglądać tak:
"date_time": {
"day": 15,
"hours": 20,
"minutes": 0,
"month": 1,
"nanos": 0,
"seconds": 0,
"time_zone": {
"id": "America/Los_Angeles"
},
"year": 2024
}
Używanie z warunkami
Warunki umożliwiają korzystanie tylko z cyfr i ciągów znaków, więc użycie najwyższego poziomu
Parametr DateTime
daje dla warunku wynik False. Przykład:
$session.params.my_dateTime.day > 5
jest prawidłowym warunkiem, ponieważ
Wartość day
jest liczbą i jest obsługiwana.
$session.params.my_dateTime > "01-01-2010"
jest nieprawidłowym warunkiem, ponieważ
„DateTime” najwyższego poziomu Obiekt nie jest liczbą ani ciągiem znaków.
Zastąpienia typu środowiska wykonawczego
Zastąpienia typów środowiska wykonawczego pozwalają dynamicznie tworzyć lub modyfikować typy w
i realizacji. Ta funkcja umożliwia dodanie lub zastąpienie specyfikacji typu w
w środowisku wykonawczym. Możesz na przykład sprawdzić źródło danych backendu, aby wczytać codzienne menu
produkty do określonego typu w realizacji.
Więcej informacji znajdziesz w przewodniku po webhookach.
na temat tworzenia zastąpień typów.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-26 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."]]