rasa icon indicating copy to clipboard operation
rasa copied to clipboard

Feature request: Allow passing dynamic timezone to duckling

Open alexmic opened this issue 5 years ago β€’ 17 comments

Rasa Core version: 0.11.12

Suppose we have a customer in Berlin (UTC+1) and we allow them to ask the following two questions:

  1. "How much have I spent 2 hours ago?"
  2. "How much have I spent between 15:00 and 16:00?"

If we configure duckling to always use UTC and the customer asks that question at 18:00, question 1 will return the correct time back (15:00 UTC, 16:00 UTC+1) but question 2 will return 15:00 UTC - 16:00 UTC, which is wrong because the customer means UTC+1.

Ducking allows tz on /parse requests which we can use to get the correct result back so is it a good idea to allow request-level component config to rasa core?

alexmic avatar Dec 05 '18 10:12 alexmic

@alexmic

I think there are two things here: Number 1 is that Duckling does not currently not actually use specified timezones (see https://duckling.wit.ai/ , Limitations)

Timezones are parsed, but they don’t impact the time value (will be fixed shortly).

The second thing is, that you want to use different time zones depending on the user, right? I think this is best done using custom actions since Rasa Core does not know the location of the user. In the custom action you can check the whether you know the location of the user, and then select the correct timezone.

wochinge avatar Dec 05 '18 12:12 wochinge

This issue has been automatically closed because there has been no response to our request for more information from the original author. Without this, we don't have enough information to help you. Please comment below with the requested information if you still need help.

no-response[bot] avatar Dec 19 '18 12:12 no-response[bot]

@wochinge This doesn't work in custom action (unless I am missing something). If the user gives absolute time (case two above) we can blindly replace the timezone of the Duckling with timezone of the user.

However, it doesn't work for relative times. For example, "last 2 hours" will give wrong results if we replace the Duckling timezone with the user timezone.

akshay2000 avatar May 28 '19 11:05 akshay2000

@akshay2000

However, it doesn't work for relative times. For example, "last 2 hours" will give wrong results if we replace the Duckling timezone with the user timezone.

Yes, but that also would not work with Duckling. I mean, how should it now the timezone of the user? Only option is to ask the user I guess.

wochinge avatar Jun 05 '19 16:06 wochinge

@akshay2000

However, it doesn't work for relative times. For example, "last 2 hours" will give wrong results if we replace the Duckling timezone with the user timezone.

Yes, but that also would not work with Duckling. I mean, how should it now the timezone of the user? Only option is to ask the user I guess.

Hence the option to send timezone with every request. As the bot sits on the client device, it can send timezone along with sender id and message. That is what I ended up doing. Had to override a bunch of methods on a bunch of core and NLU classes though.

akshay2000 avatar Jun 05 '19 16:06 akshay2000

As the bot sits on the client device, it can send timezone along with sender id and message.

That highly depends on the input channel, doesn't it?

wochinge avatar Jun 05 '19 16:06 wochinge

@wochinge I think the statement on wit.ai site is wrong. Duckling has had the timezone feature for a really long time.

I also tried with rasa's docker image:

"tonight" curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=Asia/Kolkata&text=tonight' [{"body":"tonight","start":0,"value":{"values":[{"to":{"value":"2019-12-18T00:00:00.000+05:30","grain":"hour"},"from":{"value":"2019-12-17T18:00:00.000+05:30","grain":"hour"},"type":"interval"}],"to":{"value":"2019-12-18T00:00:00.000+05:30","grain":"hour"},"from":{"value":"2019-12-17T18:00:00.000+05:30","grain":"hour"},"type":"interval"},"end":7,"dim":"time","latent":false}] curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=America/New_York&text=tonight' [{"body":"tonight","start":0,"value":{"values":[{"to":{"value":"2019-12-17T00:00:00.000-05:00","grain":"hour"},"from":{"value":"2019-12-16T18:00:00.000-05:00","grain":"hour"},"type":"interval"}],"to":{"value":"2019-12-17T00:00:00.000-05:00","grain":"hour"},"from":{"value":"2019-12-16T18:00:00.000-05:00","grain":"hour"},"type":"interval"},"end":7,"dim":"time","latent":false}]

"right now" curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=America/New_York&text=right now' [{"body":"right now","start":0,"value":{"values":[{"value":"2019-12-16T16:32:07.450-05:00","grain":"second","type":"value"}],"value":"2019-12-16T16:32:07.450-05:00","grain":"second","type":"value"},"end":9,"dim":"time","latent":false}]%

curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=Asia/Kolkata&text=right now' [{"body":"right now","start":0,"value":{"values":[{"value":"2019-12-17T03:02:20.075+05:30","grain":"second","type":"value"}],"value":"2019-12-17T03:02:20.075+05:30","grain":"second","type":"value"},"end":9,"dim":"time","latent":false}]%

mmalhotra avatar Dec 16 '19 21:12 mmalhotra

Hi guys, we had the same issue in 2018 where we needed to pass the timezone as we knew the timezone of the user, we implemented this for version 0.14.x and it works fine in our case.

https://github.com/horeapopa/rasa_nlu/commit/278fb2356739846f6547e78fcb1aed0dd8688808

The issue is that we are stuck with the old version of Rasa at the moment and looking into updating it; is there any plan of having this kind of functionality implemented?

This is the initial conversation that we had on the forum when we fixed it for us, as we did not get a confirmation of this being a priority.

https://forum.rasa.com/t/duckling-support-for-multiple-timezone-time-date-detection-rasa-nlu-duckling-timezone-date-time/1570

horeapopa avatar Feb 07 '20 22:02 horeapopa

@horeapopa @mmalhotra Can you please try to set the timezone in your model configuration as described in the Configuration section of https://rasa.com/docs/rasa/nlu/components/#ducklinghttpextractor ?

wochinge avatar Mar 03 '20 08:03 wochinge

@wochinge that is not an option when the product serves multiple timezones, there are 38 Different Local Times (https://www.timeanddate.com/time/current-number-time-zones.html) so we would need to run 38 servers (2x = 1 rasa + 1 duckling) and have logic to push each request to the appropriate one based on user timezone.

horeapopa avatar Mar 03 '20 09:03 horeapopa

@horeapopa Re-opened the issue. I don't know when we will get around doing this, if you want to pick it up I'm happy to provide help / feedback :-)

wochinge avatar Mar 05 '20 10:03 wochinge

@wochinge I've worked on this issue in https://github.com/RasaHQ/rasa/pull/8047 which seems to work fine for me.

shaswat-indian avatar Feb 25 '21 15:02 shaswat-indian

Thanks for the heads-up @shaswat-indian! @m-vdb You're having a look at the PR, right?

wochinge avatar Mar 01 '21 08:03 wochinge

@wochinge I created a new PR fixing this issue in rasa v3. Can you have a look ? It could be awesome if we can merge that in the next version.

AnthonyDurussel avatar Jan 31 '22 15:01 AnthonyDurussel

@m-vdb Any chance someone can review this PR? A 4 years old issue still not resolved while there are contributors trying to help! Please do at least let us know what you need to merge it!

natcohen avatar May 16 '22 09:05 natcohen

thanks for the nudge @natcohen, we'll triage this πŸ‘πŸ»

m-vdb avatar May 16 '22 09:05 m-vdb

@wochinge I think the statement on wit.ai site is wrong. Duckling has had the timezone feature for a really long time.

I also tried with rasa's docker image:

"tonight" curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=Asia/Kolkata&text=tonight' [{"body":"tonight","start":0,"value":{"values":[{"to":{"value":"2019-12-18T00:00:00.000+05:30","grain":"hour"},"from":{"value":"2019-12-17T18:00:00.000+05:30","grain":"hour"},"type":"interval"}],"to":{"value":"2019-12-18T00:00:00.000+05:30","grain":"hour"},"from":{"value":"2019-12-17T18:00:00.000+05:30","grain":"hour"},"type":"interval"},"end":7,"dim":"time","latent":false}] curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=America/New_York&text=tonight' [{"body":"tonight","start":0,"value":{"values":[{"to":{"value":"2019-12-17T00:00:00.000-05:00","grain":"hour"},"from":{"value":"2019-12-16T18:00:00.000-05:00","grain":"hour"},"type":"interval"}],"to":{"value":"2019-12-17T00:00:00.000-05:00","grain":"hour"},"from":{"value":"2019-12-16T18:00:00.000-05:00","grain":"hour"},"type":"interval"},"end":7,"dim":"time","latent":false}]

"right now" curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=America/New_York&text=right now' [{"body":"right now","start":0,"value":{"values":[{"value":"2019-12-16T16:32:07.450-05:00","grain":"second","type":"value"}],"value":"2019-12-16T16:32:07.450-05:00","grain":"second","type":"value"},"end":9,"dim":"time","latent":false}]%

curl -XPOST http://0.0.0.0:5006/parse --data 'dims=time&lang=en&tz=Asia/Kolkata&text=right now' [{"body":"right now","start":0,"value":{"values":[{"value":"2019-12-17T03:02:20.075+05:30","grain":"second","type":"value"}],"value":"2019-12-17T03:02:20.075+05:30","grain":"second","type":"value"},"end":9,"dim":"time","latent":false}]%

working fine to me

santhosh-sp avatar Jul 20 '22 06:07 santhosh-sp

➀ Maxime Verger commented:

:bulb: Heads up! We're moving issues to Jira: https://rasa-open-source.atlassian.net/browse/OSS.

From now on, this Jira board is the place where you can browse (without an account) and create issues (you'll need a free Jira account for that). This GitHub issue has already been migrated to Jira and will be closed on January 9th, 2023. Do not forget to subscribe to the corresponding Jira issue!

:arrow_right: More information in the forum: https://forum.rasa.com/t/migration-of-rasa-oss-issues-to-jira/56569.

sync-by-unito[bot] avatar Dec 16 '22 10:12 sync-by-unito[bot]