In this blog, we can see how to extract the date and time in a Dialogflow and personalize the responses.
Extracting the date, time, and personalize the responses are very much needed for the meeting booking bots to schedule events, restaurant bots, and reservation booking bots, etc. which would increase user engagement.
Dialogflow entities extract a keyword from a training phrase in the intent. The value is an action parameter. It is not necessary to create entities for every word in the sentence.
Dialogflow has pre-built entities called system entities. To know more about the entities, refer to this video.
Dialogflow provides many system entities to extract common keywords from user phrases. For example, the @sys.email type is used to extract values related to an email address like “email@example.com“. @sys.color type can be used to extract values like “red”, “blue”, “orange”, etc.
You can see the full list of system entities here.
System entities related to date & time
@sys.date – Matches a date
@sys.time – Matches a time
@sys.date-period – Matches a date interval
@sys.time-period – Matches a time interval
@sys.date-time – Matches date, time, intervals or date and time together
Add training phrases
We can see an example to extract data and time in a meeting booking bot and personalize the responses.
- Create an Intent, for example – Meeting Booking Bot – Schedule Meeting
- In the Training phrases section of the intent, add the training phrases as mentioned below
You could see the date and time highlighted. This means that the entity is mapped correctly. If you don’t see them highlighted, simply drag and select the date, time with the cursor and a list of entities will pop. Select the corresponding entity like @sys.date, @sys.time.
Action and parameters
After the entities are mapped in the training phrase section. In the Action and parameters section of the intent, the system entities @sys.date, @sys.time, and @sys.date-time have appeared.
The intent should match with phrases like date and time to handle the task of scheduling an appointment. However, if these phrases lack the date information or both then it will be tough because the intent cannot schedule an appointment without the time and date information.
Dialogflow provides a slot-filling feature; In which intent is matched, then the chatbot collects information from the user until the user has provided data for each of the required parameters.
- REQUIRED: If this box is ticked, The intent can’t complete without the corresponding parameter
- PROMPTS: Type of questions that the chatbot will ask your users if a request doesn’t contain this parameter.
To make the parameters $time and $date required, provide prompt questions for the parameters. The placement in the table determines the order the prompt questions. In our example, the $date parameter is above the $time parameter. If you want to change the order, drag up the parameter.
For the date parameter, the prompt is as follows:
For the time parameter, the prompt is as follows
Personalize the response
Now the chatbot can show the user, the booked appointment on the date and time mentioned by the user. So we need to personalize the response by adding a $date and $time parameter to the response as mentioned in the below example.
Make sure to obtain the date and time information once a user indicates the need for making an appointment. Now, the chatbot should be able to collect the required details for scheduling the meeting and inform the user about the scheduled date and time.
You can get the meeting booking bot from here. Thank you!
Suggested Read: How to Extract Names in Dialogflow Chatbots
Kommunicate helps companies to automate customer support and reduce costs with the use of human + chatbot hybrid model. You can signup here and reduce your customer support cost right away.