1

I'm making an app on Dialogflow and need to extract date-time info from user. So I specified a required parameter called "date-time" with @sys.date-time entity in my intent. However, when I tried to extract this parameter in my fulfillment code, I found that this parameter structure is not the same every time when I extract it. For example, when I type 12:30am into the chatbot, the returned API json response contained this:

"parameters": {
      "date-time": "2019-11-27T00:30:00-08:00",
      "log": "5"
    },

So I can directly read date-time parameter value by parameters['date-time']

However, if I type "yesterday at 2pm" into chatbot, the returned parameter structure is this:

"parameters": {
      "date-time": {
        "date_time": "2019-11-25T14:00:00-08:00"
      },
      "log": "log"
    },

See that the "date-time" parameter is wrapped inside an extra "date-time" object. This is really annoying because now i need to consider these two cases in my fulfillment code. Does anyone know why this happened? And is this a bug on my side? Thanks!

kdg
  • 11
  • 1
  • 4

1 Answers1

1

You may have found the answer to this by now, but going through Googles documentation here I found you have to consider a variety of cases when using the @sys.date-time entity. So there's nothing wrong on your end.

An extra "date_time" is used when a date and time were specified, whereas if its a period of time there's a "startDate" and "endDate" that you have to look out for inside the original "date_time" object as well.

From looking at the examples in that document I've outlined some of the cases below.

specific time (e.g.12:30am) or specific date (e.g. December 12) = single date_time object

time period (date or time e.g. April or morning) = "startDate" and "endDate" entry in a date_time object

specific date + specific time (e.g. yesterday at 2pm) = "date_time" entry in a date_time object

date + time period (e.g. yesterday afternoon) = "startDateTime" and "endDateTime" in a date_time object

Hope that helps!

samlauer
  • 11
  • 2