对话流程:今天和明天需要 return 日期和时间 - 只有 returns 日期是中午

Dialog Flow: Today & Tomorrow needs to return with date and time - only returns date with noon

我们有一个托管在服务器上的解决方案,它使用对话流将我们的话语转换为意图。 示例语句:今天的活动是什么,明天的活动是什么,今天午餐吃什么。明天中午吃什么。

我们使用实体:@sys.date-today/tomorrow 的时间。作为对这些对话流的回应,它会以这种格式(日期、中午和时区)向我们发送日期和时间:"2021-05-18T12:00:00+06:00" (+6 好像是 India IST TZ)。

一个人可以从世界任何地方请求这些查询,因此今天和明天是相对于这个人居住的地方。我们确实知道请求服务的人的 TZ。

我们使用对话流的日期、时间和 TZ 以及用户的 TZ 并计算用户日期。日期来了我们不正确。原因是 Dialog 总是 returning Time T12:00:00。如果DF给出当前时间+TZ,我们的计算就正确了。

我们如何获得对话流 return 实际时间而不是 Today/Tomorrow 的中午时间,以便我们可以为用户计算正确的日期(使用用户的 TZ - 时区)。

您可以在查询参数的 timeZone 值中传递 IANA time zone identifier,例如 America/New_YorkAsia/Kolkata,或者在代理设置中设置默认值。

来自DialogFlow ES documentation

timeZone string

The time zone of this conversational query from the time zone database, e.g., America/New_York, Europe/Paris. If not provided, the time zone specified in agent settings is used.

此外,印度的时区使用 +05:30 时差。如果您看到 +06:00,那可能是 10 个不同时区中的任何一个,但不是印度。