In this section, we'll go over the process of creating and modifying intents, annotating training phrases within that intent, and returning responses to the user.
Intents make up the bulk of your agent's functionality. To create an intent, follow these steps:
- Click on the add icon next to Intents in the menu on the left side of the Dialogflow console.
- Enter a name for your intent. Generally, your intent name should represent the kind of user queries it recognizes. For example, if you expect the user to provide their favorite color, you could name your intent
- Click SAVE.
Define training phrases
Once you've created an intent, you can define training phrases for that intent that represent what users might say. To define training phrases within an intent, follow these steps:
- Select the intent you want to define training phrases for.
- Under the Training phrases section, click the text field that says "Add user expression."
Type in your training phrases and press Enter after each. These phrases should be slightly different from each other, but express the same intent. For example, if you wanted your intent to recognize a user's input about their favorite color, you could define the following training phrases:
- "I like red"
- "My favorite color is yellow"
- "Blue is my favorite"
Once you define your training phrases, the words, phrases, or values corresponding to known entities are highlighted.
Annotate training phrases
Annotating your training phrases with entities tells Dialogflow how to parse parameters from user input. For example, if you annotated training phrases with the "color" entity, Dialogflow would recognize and extract any color parameter from user input. When Dialogflow parses parameters from user utterances, those parameters are available to you in fulfillment.
When you define your training phrases, system entities are annotated automatically and appear in the Action and parameters table; you can edit these annotations manually, if needed. The following screenshot shows the extracted system entity "color" in the Action and parameters table:
If you need to create custom entities that aren't already included in Dialogflow's system entities, you can do so manually with your own developer entities.
There are some cases where entity values in training phrases are not automatically annotated. To manually annotate an entity, follow this step:
- Highlight the value corresponding to the entity in a training phrase.
- Select the corresponding entity from the list. For example, if your training phrase is "I like red", you'd highlight "red".
After you create the entity, it appears in the entity list.
Return static responses
To return a static text response, follow these steps:
- Within an intent, scroll down to Responses.
In the text field under Text response, type a response and press Enter. Generally, your responses should guide the user to stay within the conversation's grammar. For example, if you want the user to provide their favorite color, you could define responses like "What's your favorite color?" and "What color do you like best?"
Return responses with a webhook
You can choose to return your responses using a webhook (fulfillment) rather than using the static text responses within the Dialogflow console. You must turn on fulfillment on a per-intent basis.
To enable fulfillment, follow these steps:
- Click the Fulfillment tab in the left side menu.
Click on the slider next to Webhook so it becomes enabled.
In the URL text field, enter the full URL for your webhook.
Use inline editor
- Click the Fulfillment tab in the left side menu.
Click on the slider next to Inline Editor to enable it.
Click on Deploy under the code sample.
Once you have enabled a fulfillment method, you can turn on fulfillment for individual intents. To turn on fulfillment for an intent, follow these steps:
- Within an intent, scroll down to the bottom of the page and click the arrow next to Fulfillment.
Click on the slider next to Enable webhook call for this intent.
For more information about using fulfillment, see Fulfillment.
To delete an intent, follow these steps:
- Click on the Intents tab in the navigation.
- Hover your cursor over the intent you want to delete.
- Click the trashcan icon delete_outline that appears to delete the intent.
To delete a training phrase, follow these steps:
- Locate the Training phrases section and hover your cursor over the phrase.
- Click the trashcan icon delete_outline that appears to delete the phrase.
To delete a parameter, follow these steps:
- Locate the Action and parameters table and click the three dots more_vert that appear when you hover your cursor over the parameter name.
- Click Delete from the pop-up menu.
To delete a text response, follow these steps:
- Locate the Responses section and hover your cursor over the response you want to delete.
- Click the trashcan icon delete_outline that appears to delete the response.
Intent priority allows you to assign a certain priority to an intent. If a training phrase matches multiple intents, an intent that has higher priority will be matched over an intent that is assigned a lower priority.
Change intent priority by clicking on the blue (default) dot to the left of the intent name and selecting the priority from the drop-down menu.