Skip to content

Provide timezone to Duckling API #1351

@nioc

Description

@nioc

Is your feature request related to a problem? Please describe.
I would like to use Duckling for handling date and duration but I can not provide the timezone, so the returned value is in the default (UTC-7) and

Describe the solution you'd like
Duckling parse API can handle timezone in a tz parameter, it should be useful that the BuiltinDuckling sent it (using the system one or a NER config attribute).

Describe alternatives you've considered
None.

Additional context
I'm using the Duckling Rasa docker which is not using the TZ environment variable.

Same issue on Rasa which was handled

This example show my request:

{
    "text": "shutodwn at 23:15",
    "tz": "Europe/Paris",
    "locale": "fr_FR"
}

Without the tz parameter Duckling answer 2023-08-16T23:15:00.000-07:00:

[
  {
    "body": "23:15",
    "start": 12,
    "value": {
      "values": [
        {
          "value": "2023-08-16T23:15:00.000-07:00",
          "grain": "minute",
          "type": "value"
        },
        {
          "value": "2023-08-17T23:15:00.000-07:00",
          "grain": "minute",
          "type": "value"
        },
        {
          "value": "2023-08-18T23:15:00.000-07:00",
          "grain": "minute",
          "type": "value"
        }
      ],
      "value": "2023-08-16T23:15:00.000-07:00",
      "grain": "minute",
      "type": "value"
    },
    "end": 17,
    "dim": "time",
    "latent": false
  }
]

With tz parameter, answer is correct (2023-08-17T23:15:00.000+02:00):

[
  {
    "body": "23:15",
    "start": 12,
    "value": {
      "values": [
        {
          "value": "2023-08-17T23:15:00.000+02:00",
          "grain": "minute",
          "type": "value"
        },
        {
          "value": "2023-08-18T23:15:00.000+02:00",
          "grain": "minute",
          "type": "value"
        },
        {
          "value": "2023-08-19T23:15:00.000+02:00",
          "grain": "minute",
          "type": "value"
        }
      ],
      "value": "2023-08-17T23:15:00.000+02:00",
      "grain": "minute",
      "type": "value"
    },
    "end": 17,
    "dim": "time",
    "latent": false
  }
]

A rapid fix for this should be in the builtin-duckling request function:

      const postData = querystring.stringify({
        text: utterance,
        locale: BuiltinDuckling.getCulture(language),
        tz: Intl.DateTimeFormat().resolvedOptions().timeZone,
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions