例如,假设有一条训练短语为“What is the forecast tomorrow for Tokyo?”
您应使用 date 参数为“tomorrow”添加注释,使用 location 参数为“Tokyo”添加注释。当您为训练短语的特定部分添加注释后,Dialogflow 会识别出这些部分只是最终用户将在运行时提供的实际值的示例。
对于“What is the forecast on Friday for Sydney?”这样的最终用户表述,Dialogflow 会从“Friday”中提取 date 参数,并从“Sydney”中提取 location 参数。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eTraining phrases are examples of what users might say or type, helping Dialogflow match the intent when similar expressions are used.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow's machine learning expands on the provided training phrases, so it's crucial to create at least 10-20, depending on the complexity of the intent, to cover diverse end-user expressions.\u003c/p\u003e\n"],["\u003cp\u003eAnnotating training phrases helps control how data is extracted, with Dialogflow recognizing parts as examples of values provided at runtime and providing structured data.\u003c/p\u003e\n"],["\u003cp\u003eWhile most custom entities are defined explicitly, annotating text in a training phrase can implicitly create new entity values when they don't match the selected entity type.\u003c/p\u003e\n"],["\u003cp\u003eTraining phrases should always be created using example mode, indicated by a \u003cem\u003eformat_quote\u003c/em\u003e, as template mode, which uses \u003cem\u003ealternate_email\u003c/em\u003e, is deprecated.\u003c/p\u003e\n"]]],[],null,["# Training phrases\n\n| **Note:** There are many important best practices for training phrases described in the [agent design best practices guide](/dialogflow/es/docs/agents-design#machine_learning_and_training).\n\n*Training phrases* are example phrases for what end-users might type or say,\nreferred to as *end-user expressions*.\nFor each intent, you create many training phrases.\nWhen an end-user expression resembles one of these phrases,\nDialogflow matches the intent.\n\nFor example,\nthe training phrase \"I want pizza\" trains your agent to recognize end-user expressions\nthat are similar to that phrase,\nlike \"Get a pizza\" or \"Order pizza\".\n\nYou don't have to define every possible example,\nbecause Dialogflow's built-in machine learning expands on your list with other,\nsimilar phrases.\nYou should create at least 10-20 (depending on complexity of intent) training phrases,\nso your agent can recognize a variety of end-user expressions.\nFor example, if you want your intent to recognize an end-user's expression about their favorite color,\nyou could define the following training phrases:\n\n- \"I like red\"\n- \"My favorite color is yellow\"\n- \"black\"\n- \"Blue is my favorite\"\n- ...\n\nWhere to find this data\n-----------------------\n\nWhen building an agent,\nit is most common to use the\nDialogflow ES console ([visit documentation](/dialogflow/docs/console), [open console](https://dialogflow.cloud.google.com)).\nThe instructions below focus on using the console.\nTo access training phrase data:\n\n1. Go to the [Dialogflow ES console](https://dialogflow.cloud.google.com).\n2. Select an agent.\n3. Select **Intents** in the left sidebar menu.\n4. Select an intent.\n5. Scroll down to the **Training phrases** section.\n\nIf you are building an agent using the API instead of the console, see the\n[Intents reference](/dialogflow/docs/reference/common-types#intents).\nThe API field names are similar to the console field names.\nThe instructions below highlight any important differences between the console and the API.\n\nAdd training phrases\n--------------------\n\nTo add training phrases to an intent:\n\n1. Click the text field that shows \"Add user expression\".\n2. Type your training phrases and press the `Enter` key after each.\n\nAnnotate training phrases\n-------------------------\n\n| **Note:** There are many important best practices for training phrase annotations described in the [agent design best practices guide](/dialogflow/es/docs/agents-design#machine_learning_and_training).\nWhen an intent is matched at runtime, Dialogflow provides the extracted values from the end-user expression as [parameters](/dialogflow/docs/intents-actions-parameters#params). Each parameter has a type, called the [entity type](/dialogflow/docs/entities-overview), which dictates exactly how the data is extracted. Unlike raw end-user input, parameters are structured data that can easily be used to perform some logic or generate responses.\n\nWhen building an agent,\nyou control how data is extracted by *annotating*\nparts of your training phrases and configuring the associated parameters.\n\nFor example, consider a training phrase like\n\"What is the forecast tomorrow for Tokyo?\"\nYou should annotate \"tomorrow\" with a `date` parameter and \"Tokyo\" with a `location` parameter.\nWhen you annotate parts of a training phrase,\nDialogflow recognizes that these parts are just examples of actual values that will be provided by end-users at runtime.\nFor an end-user expression like\n\"What is the forecast on Friday for Sydney?\",\nDialogflow would extract the `date` parameter from \"Friday\"\nand the `location` parameter from \"Sydney\".\n\nWhen building an agent with the console,\nmost annotations are automatically created for you when you add training phrases\nthat contain parts that can be matched to an existing\n[entity type](/dialogflow/docs/entities-overview).\nThese parts are highlighted in the console.\nYou can edit these annotations and parameters as needed.\n\nTo manually annotate a training phrase with the console:\n\n1. Select the part of the training phrase that you want to annotate.\n2. Select the desired entity type from the list.\n3. A parameter is created for you in the parameter table below.\n4. Click the **Save** button and wait until the **Agent Training** dialog indicates that training is complete.\n\nWhen building an agent with the API,\nyou must annotate training phrases and configure parameters manually.\nSee the `TrainingPhrase` and `Parameter`\ntypes in the\n[Intents reference](/dialogflow/docs/reference/common-types#intents).\nThe `Part.alias` field associates training phrase annotations with particular parameters.\n\nImplicit entities created by training phrases\n---------------------------------------------\n\n| **Note:** You should define entities explicitly, rather than rely on implicitly defined custom entity values.\n\nMost custom entities are defined explicitly by creating entity types\nand adding entity entries.\nHowever, custom entities may also contain implicit values.\nThis happens when you\n\n[annotate text of a training phrase](#annotation),\n\nwhere the annotated text is not a value defined by the selected entity type.\nThe annotated text becomes an entity reference value\nfor the implicitly added entity entry.\nIf the entity type is a map entity,\nthe text also becomes a synonym for the entity entry.\n\nExample and template modes\n--------------------------\n\n| **Caution:** Template mode is deprecated. Always use example mode for new training phrases.\n\nEach training phrase can be in one of two modes:\n\n- **Example mode** : Indicated by *format_quote* to the left of the training phrase. Training phrases in example mode are written in natural language and are annotated for parameter extraction.\n- **Template mode** : Indicated by *alternate_email* to the left of the training phrase. Training phrases in template mode contain direct references to entity types."]]