# How to handle relative time in rasa?

**URL:** <https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664>\
**Category:** Rasa Open Source\
**Created:** [June 2, 2020, 10:18am UTC](https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664 "2020-06-02T10:18:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImMihirT](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/immihirt/32/9308_2.png) [@ImMihirT](https://forum.rasa.com/u/ImMihirT)\
**Post date:** [June 2, 2020, 10:18am UTC](https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664/1 "2020-06-02T10:18:49Z")

</div>

Hi, I am working on building a chatbot which is supposed to ask the user a question like- “When task X should be done?” The user would reply saying something like- “half an hour later” or " after three hours" In return, the bot should reply- “Okay, I have scheduled the task X at 2:30 PM” Here, 2:30 PM is the relative time from the current time based on the user input. How can this functionality be achieved?

---

<div class="post-metadata">

**Author:** ![nchauras](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nchauras/32/16965_2.png) [@nchauras](https://forum.rasa.com/u/nchauras)\
**Post date:** [June 2, 2020, 11:29am UTC](https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664/2 "2020-06-02T11:29:05Z")

</div>

You can use Duckling to extract the time from user input. All you have to do is add the following lines in your `config.yml`.

![image](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/a/affafe67a186ca691bfe13bd189dbe7e29770d02.png)

Duckling will then parse user input and return the system time with type time as an entity. You will have to train your bot with some data in your `nlu.md` under some intent (e.g., ## intent:inform)

In your custom actions, you would then extract the value from entity e.g. `"timestamp": [self.from_entity(entity="time")]` in your method `slot_mappings` under `FormAction` implementation.

Arjaan Buijk very well explains this in the following webinar video:

[![](https://img.youtube.com/vi/nHqriTMRvPI/maxresdefault.jpg "Webinar: New Chatbot Starter Packs for Banking and IT Support") ](https://www.youtube.com/watch?v=nHqriTMRvPI)

You can also read more about Duckling at [https://duckling.wit.ai/](https://duckling.wit.ai/)

---

<div class="post-metadata">

**Author:** ![ImMihirT](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/immihirt/32/9308_2.png) [@ImMihirT](https://forum.rasa.com/u/ImMihirT)\
**Post date:** [June 2, 2020, 2:39pm UTC](https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664/3 "2020-06-02T14:39:38Z")

</div>

Hi, thanks for your input. Am I supposed to install duckling separately? I tried doing what was suggested in the video but got this error: 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. How do I resolve this?

---

<div class="post-metadata">

**Author:** ![nchauras](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nchauras/32/16965_2.png) [@nchauras](https://forum.rasa.com/u/nchauras)\
**Post date:** [June 3, 2020, 8:34pm UTC](https://forum.rasa.com/t/how-to-handle-relative-time-in-rasa/29664/4 "2020-06-03T20:34:37Z")

</div>

You need to start the duckling server separately using command `docker run -p 8000:8000 rasa/duckling`
