انواع
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
انواع به شما امکان می دهند موتور Assistant NLU (درک زبان طبیعی) را برای استخراج داده های ساختاریافته از ورودی کاربر پیکربندی کنید. در شرایط زیر می توانید از انواع استفاده کنید:
در intent ها می توانید عبارات آموزشی را با انواع حاشیه نویسی کنید تا اسلات ایجاد کنید. وقتی کاربران چیزی را می گویند که با یک اسلات مطابقت دارد، موتور NLU آن را به عنوان یک پارامتر تایپ شده استخراج می کند، بنابراین می توانید آن را در یک صحنه پردازش کنید.
در مرحله پر کردن اسلات یک صحنه، میتوانید چندین شکاف را مشخص کنید که میخواهید کاربر قبل از اینکه بتواند از صحنه خارج شود یا از آن خارج شود، ارائه دهد.
در مرحله شرایط صحنه، میتوانید منطق را بر این اساس قرار دهید که آیا یک پارامتر دارای مقدار خاصی است که در یک نوع تعریف شده است یا خیر.
انواع سفارشی
انواع سفارشی به شما امکان می دهد مشخصات نوع خود را ایجاد کنید تا به NLU اطلاع دهید تا مجموعه ای از مقادیر را به یک کلید اختصاص دهد. شما می توانید انواع را به روش های مختلفی مشخص کنید:
- کلمات و مترادف ها به شما امکان می دهند چندین مقدار را به یک کلید نگاشت کنید که به آنها ورودی می گویند. نوع شما می تواند شامل یک یا چند ورودی باشد. اگر این گزینه را انتخاب کنید، می توانید تنظیمات NLU زیر را نیز فعال کنید:
- فعال کردن تطابق فازی - این ویژگی اجازه میدهد تا ورودیهای دارای بیش از یک کلمه با هم مطابقت داشته باشند، حتی زمانی که کلمات به ترتیب متفاوتی گفته میشوند.
- مقادیر ناشناخته را بپذیرید - وقتی نمیتوانید همه مقادیر ممکن را تعیین کنید، پردازشگر زبان میتواند کلمات یا عبارات ناشناخته را بر اساس ورودیهای اطراف و دادههای آموزش هدف، مانند مواردی که ممکن است به فهرست مواد غذایی اضافه شوند، بپذیرد.
- عبارات منظم به نوع اجازه می دهد تا با استفاده از الگوهای عبارت منظم بر اساس استاندارد RE2 گوگل، با مقادیر مطابقت داشته باشد.
- متن فرم آزاد اجازه می دهد تا نوع با هر چیزی که کاربر می گوید مطابقت داشته باشد. حاشیه نویسی یک intent با این نوع به شما امکان می دهد تمام ورودی را به عنوان پارامتری مصرف کنید که می توانید به NLU خود منتقل کنید.
انواع سیستم
انواع سیستم به شما امکان می دهد با استفاده از داده ها و مقادیر آموزشی ارائه شده توسط سیستم، داده های شناخته شده را از ورودی کاربر حاشیه نویسی و استخراج کنید. انواع سیستم های زیر پشتیبانی می شوند:
تایپ کنید | توضیحات |
---|
actions.type.DateTime | شامل تاریخ، زمان و منطقه زمانی بر اساس تنظیمات دستگاه کاربر است. برای پر کردن اسلات و حاشیه نویسی عبارت آموزشی موجود است. |
actions.type.Date | فقط حاوی تاریخ است فقط برای پر کردن اسلات موجود است. |
actions.type.Time | فقط شامل زمان است فقط برای پر کردن اسلات موجود است. |
actions.type.Number | نوع Number با اعداد ترتیبی و اصلی مطابقت دارد. |
DateTime
، Date
و Time
این انواع بسته به محل استفاده شما از نوع و ورودی کاربر که با نوع مطابقت دارد، رفتار متفاوتی دارند.
استفاده با مقاصد
حاشیه نویسی عبارات آموزشی در intent ها فقط از نوع DateTime
پشتیبانی می کند. لازم نیست ورودی کاربر با کل مقدار DateTime
مطابقت داشته باشد. برای مثال، اگر کاربر فقط سال را ارائه دهد، پارامتر جلسه ممکن است به شکل زیر باشد:
"date_time": {
"year": 2019
}
استفاده با پر کردن اسلات
پر کردن اسلات DateTime
، Date
و Time
پشتیبانی می کند.
- اگر نوع شکاف
DateTime
باشد، دستیار از کاربر میخواهد تا یک مقدار کامل ارائه شود. - اگر نوع شکاف
Date
باشد، دستیار از کاربر میخواهد تا یک مقدار تاریخ ارائه شود. پس از جمع آوری، پارامتری که دریافت می کنید یک DateTime
کامل با زمان تنظیم شده روی 00:00 است. - اگر نوع شکاف
Time
باشد، دستیار از کاربر میخواهد تا مقدار زمانی ارائه شود. پس از جمع آوری، پارامتر دریافتی شما یک شیء کامل DateTime
با تاریخ تنظیم شده به تاریخ فعلی است.
به عنوان مثال، فرض کنید کاربری در لس آنجلس گفت: "Hey Google، یک یادآور برای 15 ژانویه 2024 در ساعت 8 شب ایجاد کنید." هنگامی که DateTime
به عنوان بخشی از فرآیند پر کردن اسلات استخراج می شود، پارامتر کامل ممکن است به شکل زیر باشد:
"date_time": {
"day": 15,
"hours": 20,
"minutes": 0,
"month": 1,
"nanos": 0,
"seconds": 0,
"time_zone": {
"id": "America/Los_Angeles"
},
"year": 2024
}
استفاده با شرایط
شرایط فقط اجازه استفاده از اعداد و رشته ها را می دهد، بنابراین استفاده از پارامتر DateTime
سطح بالا منجر به نتیجه False برای شرط می شود. به عنوان مثال:
-
$session.params.my_dateTime.day > 5
یک شرط معتبر است، زیرا مقدار day
یک عدد است و پشتیبانی می شود. -
$session.params.my_dateTime > "01-01-2010"
یک شرط نامعتبر است، زیرا شیء سطح بالا "DateTime" یک عدد یا رشته نیست.
نوع زمان اجرا لغو می شود
نادیده گرفتن نوع زمان اجرا به شما امکان می دهد تا به صورت پویا انواع را ایجاد یا تغییر دهید. این ویژگی به شما امکان می دهد در زمان اجرا، مشخصات یک نوع را اضافه یا جایگزین کنید. به عنوان مثال، میتوانید یک منبع داده پشتیبان را بررسی کنید تا آیتمهای منوی روزانه را در یک نوع در تکمیل خود بارگیری کنید.
برای کسب اطلاعات بیشتر در مورد نحوه ایجاد نادیده گرفتن نوع، به راهنمای webhooks مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]