In this hands-on workshop we will build a Hotel Booking Agent from scratch while following the best practices in conversation design. We will use Dialogflow platform to write our Agent. We use most of Dialogflow's key components and features to build an agent that users can use to search, make and manage hotel reservations. Users can include specific amenities to refine the results and book the right room.
The lessons in the workshop include:
- Using Dialogflow to build a working agent from scratch.
- Understanding and applying the best practices in conversation design.
In case you have an existing Google Cloud Platform (GCP) Account, you are good to go. If not, you should sign up now. GCP gives you a 12-month and $300 credit to get started and that is more than sufficient for the workshop. Sign up here.
Before we begin with Dialogflow, we can take a look at a sample conversation. It is important to model this, so that we have a reference conversation that we can start to mode.
User: Find a hotel in San Francisco starting on February 6 for 3 nights. Make sure it's a Hyatt.
User: I need a place to stay in Rome this weekend.
User: Is there a cheap well-rated hotel in Melbourne with free Wi-Fi?
User: Find the cheapest hotel in Brighton.
User: Reserve a hotel room for 2 adults and 2 children.
User: Can I book a room in Dallas for a week?
Follow the steps given below to build out the Hotel Booking Agent.
Sign in with your Dialogflow account. If this is your first time using Dialogflow, you will have no Agents configured. In the top-right, from the main menu, click on Create Agent as shown below:
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.
Google conversation design best practices suggests that we accomplish three main goals with welcome intent:
- Welcome the user
- Set expectations
- Let the user take control
Let's start with customizing the response of the Default Welcome Intent according to the best practice.
Based on this best practice, we can compose our agent's greeting:
Welcome. I can help you with booking or answer questions related to the hotel. Which would you like?
To update the Default Welcome Intent response, follow these steps:
- Click on the Default Welcome Intent.
- Navigate to the Responses section.
- In the Text response table, delete all the default responses.
- In the Text response table, copy and paste the following response:
-
Click SAVE.
-
Test the update using the simulator in the Dialogflow console.
In this step, we are going to model our entities. If you look at the sample conversation that we defined, we had to capture the rating (on a scale of 1 to 5) and the location of the resort.
Now, for our example, we will consider that the hotel has resorts at the following locations:
- Oakland
- San Francisco
- Concord
- Santa Clara
- San Jose
So, what we are going to do now is to define our location entity with valid values. And we shall do some interesting things i.e. define synonyms, such that if someone says Bangalore or Bengaluru, it means the same and so on for other cities too.
Let us create the resort-location entity as instructed below.
Go to Entities from the main menu. Click on CREATE ENTITY button. Give a name to the entity resort-location and create the entries as shown below, ensuring that the Define synonyms checkbox is selected.
Click on the SAVE button.
Create another entity called rating as shown below:
Remember to click the SAVE button.
You should now have the following list of entities:
Click on the Intents option in the main menu. You should see the following Intents by default:
The next thing that we are going to do now is to create our main intent i.e. booking.
Go ahead and click on CREATE INTENT.
This will bring up the New Intent screen.
Start by giving a name to the Intent i.e. booking.
We are now going to add a few sample utterances in the Training phrases field. Type the following sentences, one after the other. After entering each statement, press Enter (Return).
- book best hotel nearby
- I would like to book a room in a hotel
- 5-start hotel in San Francisco
- book 3 star hotel room
- book hotel in San Francisco for next weekend
- book a hotel with free Wi-Fi
You will notice that the application was able to extract out the rating and location entities that we created a while earlier and was able to map it to the entity names that we created (@rating and @location) as shown below:
Go to the Action and parameters section as shown below:
Click on MANAGE PARAMETERS AND ACTION and give a name to our action i.e. feedback.action
Reorder the Parameter list as shown below and do the following:
- Make both the parameters are required by selecting the REQUIRED option.
- Add a prompt to each of the parameters as given:
Prompt Text: Which city you want to book room?
The intent page should look like the following at the moment:
It is time now to start testing our Agent. In the Agent test Console on the right, where you see Try It Now field, you can test out the Agent by typing in sample utterances.
Test Case : Welcome Intent
Go ahead and type “Hello” in the Test Console, that you see on the right.
You can see that it mapped it correctly to the Default Welcome Intent. The Response field shows that it picked up the Response that we had configured for the Agent.
Test Case : Hotel booking
Go ahead and type “I want to book a room for two night in San Francisco”. The Test Console for the Agent will correctly map it to the Feedback Intent as shown below. Note that it is able to also bring forward the next question to be asked i.e. what rating would the user like to give?.
We can now publish our Agent, so that we can give it out to people to test. This is not the same as publishing the Agent for everyone to access.
To enable the Web Demo, go to the Integrations page. One of the options visible is Web Demo as shown below.
Slide the button to ON. This will show the URL and a place where you can change the icon and description for your Agent.
Click on that URL to visit the Agent in Action (a sample run is shown below).
- https://dialogflow.com/
- https://cloud.google.com/
- https://rominirani.com/hands-on-with-api-ai-google-assistant-writing-your-first-conversation-agent-a6a7dcdaba27
- https://uxdesign.cc/the-conversational-designers-guide-to-ai-assistants-by-ruben-babu-6aa45de578f0
- https://developers.google.com/actions/design/
- https://dialogflow.com/docs/samples