Build an appointment scheduler with Dialogflow

1. Before you begin

Wouldn't it be awesome to have access to an appointment scheduler at a doctor's office, department of motor vehicles office, or repair shop?

In this codelab, you'll build a simple chatbot with Dialogflow and integrate it with the web through one-click integration.

The exercises are ordered as follows:

  1. Create a Dialogflow agent.
  2. Create intent.
  3. Test the chatbot.
  4. Enable web integration.

Prerequisites

Before you proceed, you need to understand the basic concepts and constructs of Dialogflow, which you can glean from the following videos found in the Build a chatbot with Dialogflow pathway.

What you'll learn

  • How to create a Dialogflow agent
  • How to create intents in an agent
  • How to create training phrases in an intent
  • How to create responses in an intent
  • How to test a Dialogflow agent
  • How to set up web integration

What you'll build

  • A chatbot by creating an agent in Dialogflow

What you'll need

  • A browser and an email address to log into Dialogflow console

2. Create a Dialogflow agent

  1. Go to the Dialogflow console.
  2. Sign in. If you're a first-time user, then use your email to sign up.
  3. Accept the terms and conditions, and you'll be in the Dialogflow console.
  4. To create an agent**,** click d9e90c93fc779808.png, scroll to the bottom of the menu, and click **Create new agent**.

3b3f9677e2a26d93.png

  1. Enter "AppointmentScheduler" as the Agent name.
  2. Click Create.

Dialogflow creates the following two default intents as a part of the agent:

  • Default welcome intent greets your users.
  • Default fallback intent catches all the questions that your bot doesn't understand.

With that, you created a functional bot that greets users.

Test the agent

In the Dialgflow console, find the testing panel that looks like this:

3323d1bfe318688a.png

To test the agent, type "Hi" where it says Try it now. The agent should respond with the default greeting defined in the default welcome intent. It should say, "Greetings! How can I assist?" You can modify the response.

5dd38f7a78d0ef69.png

Now, if you enter "set an appointment," the agent doesn't know what to do, so it initiates the default fallback intent. That's because you haven't created any intent to catch that particular question!

3975613778643272.png

3. Create intent

  1. To create the intent, click on Intents > Create Intent. Enter "Schedule Appointment" as the Intent name.

f4fdcdfc62c76c91.png

  1. Click Training phrases and enter the following phrases.
  2. Set an appointment on Wednesday at 2 PM
  3. Need an appointment for 4 PM tomorrow
  4. I would like to set an appointment for 3 PM on Tuesday.

As you enter the phrases, you'll see time and date are automatically identified as system entities @sys.date and @sys.time.

916f91a707dfc80a.png

  1. Scroll to Responses, enter "You are all set. See you then!" as a response or you could make it more interesting and enter "You are all set for $date at $time. See you then!" (Dollar($) sign here helps you access the entity values.) Click Add Responses.

c1bc071b31817b56.png

  1. Click Save and test the agent with "set an appointment for 4 PM on Thursday." As expected, you get the response with the correct date and time.

Slot filling

Now, test "set an appointment." That's not very specific and you haven't handled that scenario, so it should be handled by the default fallback intent. To support that, you can use something called slot filling.

Slot filling allows you to design a conversation flow for parameter-value collection in a single intent. It's useful when an action can't be completed without a specific set of parameter values.

Next, set up slot filling.

  1. Click Actions and parameters. Make the entities as required, and Dialogflow asks for date and time before it responds.
  2. For time, enter "What time would you like to come in?"
  3. For date, enter "What date?"
  4. Click Save.

d5bbdb4adb6ddfbe.png

4. Test your chatbot

At this point, the Dialogflow should be set up. Enter the following conversation in the Dialogflow console where it says Try it now:

  1. User: "Hi"
  2. User: "Set an appointment"
  3. Chatbot: "What date?"
  4. User: "May 23"
  5. Chatbot: "What time would you like to come in?"
  6. User: "10am"
  7. Chatbot: "you are all set for 2019-05-23 at 10:00:00. See you then!"

5. Enable one-click web integration

Dialogflow provides many types of integration for your chatbot. Take a look at a sample web user interface for the chatbot.

Click Integrations in the Dialogflow console.

Enable Web Demo.

27b74328cc705181.png

Click the URL to launch Web Demo. d389ab871032c565.png

Start using the chat interface by typing where it says Ask something. Use the following conversation:

  1. Enter "Hi" and the chatbot should respond as before.
  2. Enter "set an appointment for 4 PM tomorrow" and the chatbot should respond by confirming the appointment.

6. Clean up

If you plan to complete other codelabs that involve Dialogflow, then skip this section for now and return to it later.

Delete the Dialogflow agent

  • Click fe9c61cc27fb9f2e.png next to your existing agent.

79eb93054b2bb876.png

  1. In the General tab, scroll to the bottom and click Delete This Agent.
  2. Type Delete in the dialog that appears and click Delete.

7. Congratulations

You built a chatbot and now you're a chatbot developer!

Learn more

Check out some other Dialogflow resources: