Search code examples
timezonedialogflow-es

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


We have a solution hosted on a server which uses Dialog Flow to convert our utterances to intent. Example utterances: What are the activities for today, What are the activities for tomorrow, What is for lunch today. What is for lunch tomorrow.

We use entity: @sys.date-time for today/tomorrow. In response to these Dialog Flow sends us a date and time in this format (date, noon and time zone): "2021-05-18T12:00:00+06:00" (+6 seems to be India IST TZ).

A person can request these queries from anywhere in the world, hence today and tomorrow is relative to where the person is residing. We do know the TZ of the person requesting the service.

We use the Dialog flow's date, time and TZ and the TZ of the user and calculate the users date. The date comes our incorrect. Reason being that Dialog is always returning Time T12:00:00. If DF gave current time + TZ, our calculations would be correct.

How do we have Dialog Flow return actual time and not noon for Today/Tomorrow, so we can calculate the correct date for the user (using user's TZ - Time Zone).


Solution

  • You can pass an IANA time zone identifier such as America/New_York or Asia/Kolkata in the timeZone value in the query parameter, or set a default in the agent settings.

    From the 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.

    Also, India's time zone uses a +05:30 offset. If you're seeing +06:00, that could be any of 10 different time zones, but it's not India.