A Complete Guide to Recording Time & Date Periods With a Chatbot
Dates are the key parameter that is mandatory in numerous business scenarios like Leave or Travel Request Creation, generating conversational reports for backend data for the date or period. However, it sometimes appears to be a challenge to record various date formats and combinations (one date, several dates, period).
This tutorial is meant to be for advanced users, so if you haven’t built your first bot, follow this tutorial.
If you want to learn how to master memory management using the bot builder on the SAP Conversational AI platform, please read this article first!
The best practices here from a re-usability and unified skills development perspective could be to use one skill only to address the tasks of getting a single date, several dates, or a period in different situations. In this case, we first capture any date input entity that we receive from the chat user (there can be two dates, a single date, or a period that is also a standard entity).
We try to capture at least one #datetime entity (Date From) (1) or an #interval entity (as Date From and Date To parameters) (2) in the Requirements tab:
Saving the Date From value from the #datetime entity, we capture the first element of an array of dates and record the ISO part of the standard entity. This is quite good practice to record standardized values, as it might be vital for integration:
In the #Interval entity processing, we record the beginning and end of the time period to distinguish between these memory parameters:
Additionally, if the user provides two separate dates in one message (not as a time period), we record the Date To value as the second element of the #datetime array in the Actions tab of the skill:
If our scenario presupposes the availability of two dates, but the user initially provides only one date, then we have an additional check for the required memory parameter presence (Date To):
If such a memory parameter is missing (the second date, Date To in our example), we ask the user to input the appropriate date in the main skill (Leave Request Creation, for example) and we call an additional skill that records that second date in the Requirements tab:
In this case, once we have already asked the user about the second date (Date To in our case), we record the first element of the #datetime array as the Date To memory parameter:
At this stage, we might ask ourselves the following question: “What if the user decides to provide the date at once, without waiting for the bot’s clarifying question?”
We have a solution for this case too. In the main business skill, there are two types of action blocks:
1. If the entity is allocated and the target parameter is empty, the Get Date skill is called directly, and the date is recorded straightaway:
2. If the target entity is not recognized, then we ask the date to be provided, and redirect to the Get Date skill with the Wait for User Input option:
Here, we have a unified mechanism that allows us to record any combination of dates and any kind of data input!
Case 1: Record One Date: Half-Day Leave Request Creation
This skill allows the user to create a leave request for up to one day. The period of leave is given in hours. In this scenario, we need to record one date from the user input.
Case 2: Record Period (Date From – Date To): Travel Request Creation
This AI skill enables SAP users to create a travel request for their coming trip. The chatbot will ask for necessary details such as dates, destination, expected travel expenses, etc. In this case, the bot requests the start and end dates of the trip.
Case 3: Option to Decide – One or Two Dates: Educational Leave Creation
By educational leave, we mean time taken off for the purpose of self-studies and upgrading one’s qualification. The user can ask for a leave of one day or longer – our chatbot will always clarify this point.
Case 4: Record Two (or More) Separate Dates: Supplier Invoice Creation
This functional skill allows the chat user to create a supplier’s invoice. Here, we need to record two independent dates: The date of the document and the posting date.