Duckling support for multiple timezone time/date detection [Rasa NLU] [Duckling] [Timezone] [Date] [Time]

We have just started using Duckling with Rasa for scheduling. There is an important issue we ran into that I don’t see addressed in the community support.

We want to support both relative times (e.g in 3 hours) and absolute times (e.g at 6 pm). Say a user is in PDT and the time now is 8 am PDT (11 am EDT) and we keep the default Rasa/Duckling setting of EDT.

Relative: in 3 hours -> Duckling returns 2 pm EDT which is 11 am PDT (since its 3 hours from 11 am EDT). This is CORRECT

Absolute: at 2 pm -> Duckling returns 2 pm EDT which is 11 am PDT. This is INCORRECT.

As you can see there doesn’t seem to be a single deterministic way to get the time right. We do want to support all US timezones at least. We had the same issue with AWS Lex but they support passing in timezone as a separate attribute in the input.

  - Is there a way to configure the timezone in the input sent to Rasa?
  - Or can we know whether the user utterance was relative or absolute?

Appreciate your response on this.

1 Like

There is a pull request for this feature from what I can see, am I right that this was already implemented and release?

Of what release is this part of if any of you know?

if you install the latest version (0.13.5) it should be part of that

TL;DR:

Need to run single server for Rasa/Duckling that supports multiple timezones as user input on /parse endpoint; is this possible?

$ curl -XPOST localhost:5000/parse -d '{"q":"tomorrow at eight", "tz": "US/Pacific"}'
    
{"value":"2018-10-16T08:00:00.000-04:00"}
$ curl -XPOST localhost:5000/parse -d '{"q":"tomorrow at eight", "tz": "US/Eastern"}'

{"value":"2018-10-16T08:00:00.000-07:00"}

LONG:

Installed the latest build but we are running into the same issue, we need to pass the timezone to Rasa and Rasa to pass it down to Duckling.

From what I experimented and read from the docs this is not possible, you can set the timezone in the Rasa/Duckling config but this is limiting the use of the Rasa server to one single timezone (eg. if you need to use Rasa for multiple timezones we would need to have at least one Rasa instance per timezone)

pipeline:
- name: "ner_duckling_http"
  # url of the running duckling server
  url: "http://localhost:8000"
  # dimensions to extract
  dimensions: ["time", "number", "amount-of-money", "distance"]
  # allows you to configure the locale, by default the language is used
  locale: "de_DE"
  # if not set the default timezone of Duckling is going to be used
  # needed to calculate dates from relative expressions like "tomorrow"
  timezone: "Europe/Berlin"

What we would need is to have a single instance of Rasa that could take as input the timezone of the user and compute the date based on that, this is possible if Rasa would pass this on to Duckling, sample Duckling queries:

curl -XPOST http://0.0.0.0:8000/parse --data "locale=en_GB&text=tomorrow at eight&tz=US/Eastern&reftime=1539602179354"
[{"body":"tomorrow at eight","start":0,"value":{"values":[{"value":"2018-10-16T08:00:00.000-04:00","grain":"hour","type":"value"},{"value":"2018-10-16T20:00:00.000-04:00","grain":"hour","type":"value"}],"value":"2018-10-16T08:00:00.000-04:00","grain":"hour","type":"value"},"end":17,"dim":"time","latent":false}]
curl -XPOST http://0.0.0.0:8000/parse --data "locale=en_GB&text=tomorrow at eight&tz=US/Pacific&reftime=1539602179354"
[{"body":"tomorrow at eight","start":0,"value":{"values":[{"value":"2018-10-16T08:00:00.000-07:00","grain":"hour","type":"value"},{"value":"2018-10-16T20:00:00.000-07:00","grain":"hour","type":"value"}],"value":"2018-10-16T08:00:00.000-07:00","grain":"hour","type":"value"},"end":17,"dim":"time","latent":false}]

this doesn’t work no, you could however in a custom action get the location of the user, and then convert the time to their timezone

After some digging around and reading a bit of python added support for timezone passing:

<rasa_url>/parse?q=tomorrow%20at%2010&model=<model>&tz=US/Eastern

Hi, to enable the component ‘ner-duckling_http’ in the pipeline, what else do i need to do in my python script except updating the config file as below:

pipeline:
- name: "ner_duckling_http"
  # url of the running duckling server
  url: "http://localhost:8000"
  # dimensions to extract
  dimensions: ["time", "number", "amount-of-money", "distance"]
  # allows you to configure the locale, by default the language is used
  locale: "de_DE"
  # if not set the default timezone of Duckling is going to be used
  # needed to calculate dates from relative expressions like "tomorrow"
  timezone: "Europe/Berlin"

I have below errors when i run the model as a server via ‘python -m rasa_nlu.server --path models --port 8080 &’:

ERROR rasa_nlu.extractors.duckling_http_extractor - Failed to connect to duckling http server. Make sure the duckling server is running and the proper host and port are set in the configuration. More information on how to run the server can be found on github: GitHub - facebook/duckling: Language, engine, and tooling for expressing, testing, and evaluating composable language rules on input strings. Error: HTTPConnectionPool(host=‘localhost’, port=8000): Max retries exceeded with url: /parse (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7fffa2f92ba8>: Failed to establish a new connection: [Errno 111] Connection refused’,))

Check whether you have any firewall blocking 8000 port. You might have a proxy attached to your bot. In this case, export NO_PROXY=localhost

Thanks. It turns out that I forgot to run the duckling as a server at first.

Can you please help sharing how did you run this as a server and the configuration used for that. Thanks in advance.

Using the docker tool to run it as a server.

  1. docker pull rasa/duckling
  2. then run `docker run -p 8000:8000 rasa/duckling