cancel
Showing results for 
Search instead for 
Did you mean: 

Datetime Gold Entity. Usage for UK and US Regions

natarajannaraya
Explorer

Hi Team,

We are using Datetime Gold Entity in one of our CAI requirements to capture a date.

The chatbot can be used both in US and UK regions where the users follow two different date formats MYD and DMY.

How does the bot understand that it's a MMDDYYYY or DDMMYYYY based on the user's login or location. Please suggest.

Thank you.

Accepted Solutions (0)

Answers (2)

Answers (2)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

In order to do what you want, you would have to know where the user came from, or at least what date format they used. I don't see a way to know where they come from in the chatbot (no country, only language, UTC indicator), and therefore you would have to detect the user and check their preferences in your system.

If you could do that, then you could intercept the input and change it to the format you wanted (or interpret it as the format you wanted).

former_member523146
Participant
0 Kudos

The DMY format has precedence. Only if that format is not able to parse a valid date, the MDY format is tried. As of now, the locale of the chat user is not taken into consideration.

E.g. the output for the two dates "12/01/1999" (valid DMY) and "13/01/1999" (invalid DMY) is

{
    "confidence": 0.99,
    "raw": "12/01/1999",
    "iso": "1999-12-01T00:00:00+00:00",
    "formatted": "Wednesday, 01 December 1999 at 12:00:00 AM (+0000)"
}

{
    "confidence": 0.99,
    "raw": "13/01/1999",
    "iso": "1999-01-13T00:00:00+00:00",
    "formatted": "Wednesday, 13 January 1999 at 12:00:00 AM (+0000)"
}