Create and manage intents

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.

Create intents

Intents make up the bulk of your agent's functionality. To create an intent, follow these steps:

  1. Click on the add icon next to Intents in the menu on the left side of the Dialogflow console.
  2. 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 favorite_color.
  3. 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:

  1. Select the intent you want to define training phrases for.
  2. Under the Training phrases section, click the text field that says "Add user expression."
  3. 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"
    • "black"
    • "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:

  1. Highlight the value corresponding to the entity in a training phrase.
  2. Select the corresponding entity from the list. For example, if your training phrase is "I like red", you'd highlight "red".
  3. Select the @sys.color entity.

After you create the entity, it appears in the entity list.

Return static responses

Each intent should return a response, whether that is a static response or a dynamic response returned from a webhook.

To return a static text response, follow these steps:

  1. Within an intent, scroll down to Responses.
  2. 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?"

  3. Click Save.

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:

  1. Click the Fulfillment tab in the left side menu.
  2. Click on the slider next to Webhook so it becomes enabled.

  3. In the URL text field, enter the full URL for your webhook.

Use inline editor

Alternatively, you can use Dialogflow's inline editor to build and manage fulfillment. Within the inline editor, you can write your fulfillment webhook in JavaScript and quickly deploy your code to Cloud Functions for Firebase. To deploy your code using the inline editor, follow these steps:

  1. Click the Fulfillment tab in the left side menu.
  2. Click on the slider next to Inline Editor to enable it.

  3. 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:

  1. Within an intent, scroll down to the bottom of the page and click the arrow next to Fulfillment.
  2. Click on the slider next to Enable webhook call for this intent.

  3. Click Save.

For more information about using fulfillment, see Fulfillment.

Manage intents

To delete an intent, follow these steps:

  1. Click on the Intents tab in the navigation.
  2. Hover your cursor over the intent you want to delete.
  3. Click the trashcan icon delete_outline that appears to delete the intent.

To delete a training phrase, follow these steps:

  1. Locate the Training phrases section and hover your cursor over the phrase.
  2. Click the trashcan icon delete_outline that appears to delete the phrase.

To delete a parameter, follow these steps:

  1. Locate the Action and parameters table and click the three dots more_vert that appear when you hover your cursor over the parameter name.
  2. Click Delete from the pop-up menu.

To delete a text response, follow these steps:

  1. Locate the Responses section and hover your cursor over the response you want to delete.
  2. Click the trashcan icon delete_outline that appears to delete the response.

Intent priority

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.