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:
- Create a Dialogflow agent.
- Create intent.
- Test the chatbot.
- Enable web integration.
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
- Go to the Dialogflow console.
- Sign in. If you're a first-time user, then use your email to sign up.
- Accept the terms and conditions, and you'll be in the Dialogflow console.
- To create an agent**,** click , scroll to the bottom of the menu, and click **Create new agent**.
- Enter "AppointmentScheduler" as the Agent name.
- 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:
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.
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!
- To create the intent, click on Intents > Create Intent. Enter "Schedule Appointment" as the Intent name.
- Click Training phrases and enter the following phrases.
- Set an appointment on Wednesday at 2 PM
- Need an appointment for 4 PM tomorrow
- 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.
- 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.
- 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.
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.
- Click Actions and parameters. Make the entities as required, and Dialogflow asks for date and time before it responds.
- For time, enter "What time would you like to come in?"
- For date, enter "What date?"
- Click Save.
At this point, the Dialogflow should be set up. Enter the following conversation in the Dialogflow console where it says Try it now:
- User: "Hi"
- User: "Set an appointment"
- Chatbot: "What date?"
- User: "May 23"
- Chatbot: "What time would you like to come in?"
- User: "10am"
- Chatbot: "you are all set for 2019-05-23 at 10:00:00. See you then!"
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.
Click the URL to launch Web Demo.
Start using the chat interface by typing where it says Ask something. Use the following conversation:
- Enter "Hi" and the chatbot should respond as before.
- Enter "set an appointment for 4 PM tomorrow" and the chatbot should respond by confirming the appointment.
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 next to your existing agent.
- In the General tab, scroll to the bottom and click Delete This Agent.
- Type Delete in the dialog that appears and click Delete.
You built a chatbot and now you're a chatbot developer!
Check out some other Dialogflow resources: