This post is a followup for Building your first [smart] bot in 10 minutes. Do give it a read before reading this post. In this post we will be building a chatbot that will handle hotel booking. There will be minimal [python] code and it will be hosted on a serverless instance of aws.
Things you will learn in this post –
- Fine tuning your dialogflow intents
- Using entities
- Using contexts
> Creating Intents
You can think of intents as intention. “What is your name?“, The intention of this question is to get the name of the person the question was asked to. Now, I can use different sentences to have the same intention –
- Can you tell me your name?
- What do people call you ?
All the questions have the same intention – to get the persons name.
To create intents, click on the intents tab and add training phrases.
To make hotel bookings I will need the following parameters
- Number of people
- A date
- Number of nights for the stay
For now let the two training phrases be –
Entities are information that you want to extract from the user inputs. In the above image you can spot three entities that we are taking from the user input.
You can change the parameter name by double clicking it.
To book a hotel room you need all the three entities mentioned above. Scroll down to action and parameters and select the required checkbox for all three parameters.
Click on the prompts that will be displayed if the user fails to give one of the three entities.
Everything seems to be working well. But we still need to ask the user and confirm the given information. To send back a response, scroll down to the response tab and use $parameter_name where ever required.
Context provide you with background information of what’s being talked about.
Ashish doens’t like slow internet. He also not too fond of buggy interfaces.
The second sentence will not make much sense without the first one. Who is “he” ? In dialogflow you can pass variables from one intent to another using context.
To do that, click on the context for your first intent and add a identifier for that intent. Now go to the next intent and put that indentifier as your input context. You can later use the parameters from the first intent in second one using