Date / Birthdate Recognition
This service extension provides more control over how dates are parsed if they are given in an unusual format, especially in combination with STT issues.Example flow with the birthdate serviceService configurationsuccess : a valid result was returnedambiguous : the input was ambiguous, and resultList contains multiple optionsinvalid: the input could not be mapped to a valid dateutterance: The raw utterance of the user. You can retrieve it in a storage block with intent.rawPlatformRequestBody.text (phoneV2 only) and use the storage variable subsequently in the service call.slot: The automatically extracted dateTime slot (ensure that it is activated in your speech assets).twoDigitThreshold: Configuration parameter that describes when a year is given only as two digits (e.g. 90 instead of 1990), until which number it is assumed to be 19XX vs 20XX. The default behavior of the current slot extraction uses the closest date to today, which makes 60 become 2060. This allows controlling this by setting it to a lower number, e.g. 20, which results in 20 -> 2020 but 21 -> 1921.maxYear: Configuration parameter that describes the maximum year that is considered a valid result. Use if e.g. for birthdate checking, by setting it to the current year if any past date is valid, or to a year that is assumed to be the minimum age of users contacting your bot (e.g., today minus 16 or 18 years: moment().year() - 18).locale: Locale of the input. Currently only de is supported (default: de).partialReturn: Set it to any non-empty value to have the day and month of dates that are beyond the maxYear returned instead of returning an empty result.mode: This optional input field defines which of the 3 possible modes of the Service you choose to use, from the options: birthday, pastdate, futuredate . The default value of the Service is birthday, even when this field is not used/filled. Further usage of pastdate and futuredate modes are explained further below. This input field is case insensitive, as parsing is performed in the service.result: The first valid resultresultList: The full list of valid options in case an ambiguous input is receivedyear: Year of the main result. Empty if partialReturn is active and the input/recognized year is bigger than maxYear.month: Month of the main result.day: Day of the main result.URL: https://parloaservices.azurewebsites.net/api/ParseBirthdate?code=<AUTHCODE>&clientId=<CLIENTID> (you can get your own AUTHCODE and CLIENTID from your Parloa representative)Note that the URL includes the API key to access the function. No separate header is needed.Dialog usageAdd the service to your dialog as usual. A sample input set is shown below:utteranceslotlocaletwoDigitThresholdmaxYearpartialReturnThe raw input of the user, usually obtained by using a storage block before the service call and setting a variable (e.g., utterance
) to the Javascript value of intent.rawPlatformRequestBody.text
.Add it to the input by clicking the plus-symbol, or typing "+" and selecting the storage variable set in the previous storage block.
Service modes
birthdaypastdatefuturedateThe futuredate
value is used when the input value of the utterance is expected to be in the future.The logic is as follows:
If the utterance field contains a date in the future, then it is parsed and returned in the respective output fields, with a success branch output.
Otherwise, an invalid result is returned, with no output in the output fields.
The futuredate
mode does not handle only complete dates (e.g. dd-mm-yyyy
) as input, rather it analyses the input of the user and it tries to generate valid dates with the input given. In case of incomplete input dates, such as when we don't specify the year, the service will try to complete them as a day in the future. In the other cases where the year is specified, the service will not try to alter the date to convert it to a future date. In ambiguous cases, such as when a number may be interpreted as a month or as a year, the service returns only those dates which are future dates. Further examples are detailed in the following section.
Result examples
Two Digit YearAmbiguous unformattedPartial returnFuturedate modePastdate mode
1.Month input utterance that the service converts into a past date:
{"input": {"utterance": "02 Dezember","twoDigitThreshold": "19","maxYear": "2025","mode": "pastDate"}}Output: Year is set to 2022
because the of the pastdate
mode defined{"choice": "success","output": {"result": "2022-12-02","year": "2022","month": "12","day": "02"}}2. The following input utterance is an incomplete date, which the service handles as shown:{"input": {"utterance": "01 11","slot": "","twoDigitThreshold": "80","maxYear": "2024","mode": "pastDate"}}Output: The service can detect from the input utterance:
Input is given as "dd mm" => converted to 22-11-01
Input is given as "mm yy" => converted to 11-01-01
{"choice": "ambiguous","output": {"result": "2022-11-01","year": "2022","month": "11","day": "01","resultList": "2022-11-01,2011-01-01"}}The today
date is "10-Jan-23" for both these examplesâ