Create and customize an agent

In Dialogflow, a newly created agent comes with two default intents, the Default Welcome Intent and the Default Fallback Intent. The first steps of building an agent, in addition to creating new intents, involve customizing these intents to match the purpose and persona of your agent.

Log in to Dialogflow

First, log in to the Dialogflow console using your Dialogflow account. If you don't have a Dialogflow account, follow the instructions on this page to create a new account.

Create an agent

To create an agent, follow these steps:

  1. In the Dialogflow console, create a new agent.
  2. Name the agent MarysBikeShop.
  3. Click CREATE.

Customize the Default Welcome Intent

Let's start with customizing the response of the Default Welcome Intent according to the Google conversation design best practices. The best practice suggests that you accomplish three main goals with your greeting: welcome the user, set expectations, and let the user take control.

Based on this best practice, we can compose our agent's greeting:

Welcome. I can tell you the shop hours, or I can set up an appointment. Which would you like?

To update the Default Welcome Intent response, follow these steps:

  1. Click on the Default Welcome Intent.
  2. Navigate to the Responses section.
  3. In the Text response table, delete all the default responses.
  4. In the Text response table, copy and paste the following response:

    Welcome. I can tell you the shop hours, or I can set up an appointment. Which would you like?

  5. Click SAVE.

  6. Test the update using the simulator in the Dialogflow console.

    Figure 2. Flowchart showing the Welcome intent with its matched utterance and response.

Create response variants

After composing a new greeting phrase, we need to create other variations. Include the following variations as responses in the Default Welcome Intent:

  • Welcome. I can tell you the shop hours, or I can make an appointment. What can I do for you?
  • Hello there. I can tell you the shop hours, or I can schedule an appointment. How may I help you today?

When we supply multiple responses for an intent, Dialogflow randomly selects a response variant from the list. However, keep in mind that there are more sophisticated ways to handle variations in responses once we start writing code for fulfillment, which enables an intent to employ complex logic. Dialogflow's fulfillment component is covered in later sections.

In our response variants, the greeting phrases end with a question, such as "Which would you like?" and "What can I do for you?" At this point, the agent expects an utterance from the user, and the utterance should reveal what the user wants from the agent. In the next section, we create the agent's first custom intent that can identify and resolve a user's request.

Create a custom intent

We want the bike shop agent to perform two tasks:

  • Inform customers about the hours of operation
  • Schedule appointments for customers

Let's first create an intent that can inform users about the hours of operation for the bike shop. We can start by writing a sample dialog for this intent:

      User: When are you open?

      Agent: We're open from 9 AM to 6 PM every day. Is there anything else I can do for you?

To create an intent that can handle this dialog, follow these steps:

  1. Create a new intent named Hours.
  2. In the Training phrases section of the Hours intent, enter the following training phrase: When are you open?
  3. In the Responses section, enter the following response in the Text response table: We're open from 9 AM to 6 PM every day. Is there anything else I can do for you?
  4. Click SAVE.

    Figure 3. Flowchart showing the Default Welcome Intent and the new custom intent, Hours.

The setup above gives us a basic intent that works. When a user asks the question "When are you open?", Dialogflow matches the user utterance with the custom intent Hours. Then, the intent responds with the phrase "We're open from 9 AM to 6 PM every day. Is there anything else I can do for you?"

Add more training phrases

Since the Hours intent currently has only one training phrase, "When are you open?", the intent has insufficient knowledge to identify other similar utterances that have the same meaning. We need to provide more training phrases so the agent can match a variety of user utterances that express the same intention.

In natural language, we almost always have different ways of forming phrases that mean the same thing. We recommend that every intent begins with at least 10 training phrases. As you start testing the agent, continue to add more training phrases using Dialogflow's Training tool.

With the phrase "When are you open?", we can come up with these 10 variations that users may say instead:

  • Are you open today?
  • How late are you open on weekends?
  • When do you close?
  • What time do you open tomorrow morning?
  • Are you open now?
  • Business hours.
  • How early can I drop in?
  • Tell me your opening hours.
  • What are your hours?
  • How late can I come in?

To add these variations as training phrases, follow these steps:

  1. Click on the Hours intent.
  2. In the Training phrases section, copy and paste each phrase above.
  3. Click SAVE.
  4. Test the intent with various user utterances using the simulator in the Dialogflow console.

So far, we have an agent that can greet and welcome users and identify and resolve a specific request from the users. However, what happens when users say something that can't be understood by the agent?

In the next section, we'll explore a special intent that is designed to handle unmatched utterances: a fallback intent.

Customize the fallback intent

A fallback intent is a special intent that is matched when a user utterance is not matched with any other intents. Like the Default Welcome Intent, a generic fallback intent named Default Fallback Intent is included in every agent.

A fallback intent can prompt users to form utterances in a format that the agent can understand. To update the Default Fallback Intent response, follow these steps:

  1. Click on the Default Fallback Intent.
  2. Navigate to the Responses section.
  3. In the Text response table, delete all the default responses.
  4. In the Text response table, copy and paste the following response:

    Sorry, did you want to hear our hours, or set up an appointment?

  5. Click SAVE.

    Figure 4. Flowchart showing the fallback intent in the top left corner.

The prompt question in the fallback response—"did you want to hear our hours, or set up an appointment?"–guides users to provide a recognizable utterance. The agent should expect one of the following utterances from the user: "I want to know the hours" or "I want to set up an appointment".

At this point, our agent doesn't have an intent that can handle the utterance "I'd like to set up an appointment." In the following section, we'll create an advanced intent that can resolve the request to set up an appointment.