Training phrases are example phrases for what end-users might type or say, referred to as end-user expressions. For each intent, you create many training phrases. When an end-user expression resembles one of these phrases, Dialogflow matches the intent.
For example, the training phrase "I want pizza" trains your agent to recognize end-user expressions that are similar to that phrase, like "Get a pizza" or "Order pizza".
You don't have to define every possible example, because Dialogflow's built-in machine learning expands on your list with other, similar phrases. You should create at least 10-20 (depending on complexity of intent) training phrases, so your agent can recognize a variety of end-user expressions. For example, if you want your intent to recognize an end-user's expression about their favorite color, you could define the following training phrases:
- "I like red"
- "My favorite color is yellow"
- "Blue is my favorite"
Where to find this data
- Go to the Dialogflow ES Console.
- Select an agent.
- Select Intents in the left sidebar menu.
- Select an intent.
- Scroll down to the Training phrases section.
If you are building an agent using the API instead of the console, see the Intents reference. The API field names are similar to the console field names. The instructions below highlight any important differences between the console and the API.
Add training phrases
To add training phrases to an intent:
- Click the text field that shows "Add user expression".
- Type your training phrases and press the
Enterkey after each.
Annotate training phrasesWhen an intent is matched at runtime, Dialogflow provides the extracted values from the end-user expression as parameters. Each parameter has a type, called the entity type, 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.
When building an agent, you control how data is extracted by annotating parts of your training phrases and configuring the associated parameters.
For example, consider a training phrase like
"What is the forecast tomorrow for Tokyo?"
You should annotate "tomorrow" with a
date parameter and "Tokyo" with a
When you annotate parts of a training phrase,
Dialogflow recognizes that these parts are just examples of actual values that will be provided by end-users at runtime.
For an end-user expression like
"What is the forecast on Friday for Sydney?",
Dialogflow would extract the
date parameter from "Friday"
location parameter from "Sydney".
When building an agent with the console, most annotations are automatically created for you when you add training phrases that contain parts that can be matched to an existing entity type. These parts are highlighted in the console. You can edit these annotations and parameters as needed.
To manually annotate a training phrase with the console:
- Select the part of the training phrase that you want to annotate.
- Select the desired entity type from the list.
- A parameter is created for you in the parameter table below.
When building an agent with the API,
you must annotate training phrases and configure parameters manually.
types in the
Part.alias field associates training phrase annotations with particular parameters.
Example and template modes
Each training phrase can be in one of two modes:
- 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.
- Template mode: Indicated by alternate_email to the left of the training phrase. Training phrases in template mode contain direct references to entity types.