Teneo's DateTime Handler comes with a wide range of pre-defined date and time expressions together with their interpretations. However, if you want to modify the existing date time expressions or add new date or time expressions to be recognized by your bot, you can add them directly to your solution with no advanced scripting skills required. On this page we will show you how to:
As we have previously seen, the DateTime Handler consists of two parts: a DateTime library and a DateTime interpretation script. You may make changes to both components, depending on what you want to change. In order to broaden the coverage of the recognition, you will have to make changes to the DateTime library. If you only want to change the interpretation of an existing date or time expression, you will add a few lines of code to the pre-processing script.
If you want to adjust the recognition of date or time expressions, this is how to go about:
At runtime, only this locally modified version of the language object will be used, as local language objects always have precedence over the language objects of imported libraries.
Important Note: when editing the local copy make sure to use only existing NLU variables and values. Otherwise, the DateTime interpretation script will not be able to map the representation to date and time expressions.
Sometimes the expression you want to change is already coverd by the DateTime Handler, but you are just not happy with its interpretation. For example, how to interpret "lunch" time greatly varies depending on local preferences. Say we want to change the interpretation of "lunch" time from 12:00 to 13:00 in all flows of our solution. This is what we have to do:
For the modification of named dates, there is a method called 'addNamedDates'. Say you want to change the interpretation of mother's day (which differs depending on the country), then simply add
datetime.Handler.addNamedDate('mothers_day', '2019-05-08') to the pre-processing script. Note that you can this way only change the interpretation of already existing named dates and times of the DateTimeHandler. In the following we will show you how to add new dates and times to the DateTime library and their interpretations.
The DateTimeHandler comes with a number of pre-defined named dates like "Christmas Day" or "New Year's Eve". However, sometimes you may want to add your own named dates. We will show you here how to go about if you want to add named dates or modify interpretations of existing named dates:
In the following, we will show you how to add the 'Longberry Baristas Day' to the DateTime library:
DT_NAMED.LIST. This name must be identical to the language object you have copied the content from. This will ensure that Teneo will use the local copy instead of the original.
Longberry Baristas' day is now recognized by the grammar, so now it's time to add an interpretation for it as well:
If you want to define a range, simply pass two dates or two times instead of one. For example, the Longberry Happy Hour lasting from 17:00 to 18:00 is added like this:
datetime.Handler.addNamedTime('longberry_happy_hour', '1700', '1800')
Was this page helpful?