How to make the chatbot to calculate a time interval?

Hello everyone,

I would like to ask, I am working on a chatbot to help me keep track of seminars in a Google Spreadsheet as my db. And I want my form flow to be similar to this:

- user: I want a list of ML seminars
- bot: Are you interested in a specific time period?
- user: in three months from now (or in December)

Assume that in my spreadsheet I have a column that contains the date of the seminar will happen. My goal is, the chatbot to be able to extract the quantity “three months” as 3 and add it to the current month or extract the value “December” and transform it to 12 and then return all the seminars on this specific month. Atm, I am using python’s package datetime to work with dates.

In config.yml I am using DIET and Duckling which results in a contradiction when need to extract the “time” feature. In addition, I am not able to transform “three months” to a number 3 in order to use it in my custom actions.

Any suggestions on this?

1 Like

You don’t need to use DIET to extract things that Duckling can do (so you shouldn’t use Diet for things like dates, time, numbers, etc.)

The Duckling output format for “3 months” should already be structured something like “< integer > < unit-of-duration >”, so you’ll just need to parse it correctly into Python. I’d probably use dateutil for your application since it can handle relative dates without needing to do a bunch of fussing with base datetime.

Hope that helps!

1 Like

Hey, @rctatman thank you for your response and your videos :grinning_face_with_smiling_eyes:. Is there a way to set the DIET to not classify these things? For example, with Duckling I can define the dimensions, I looked for something similar with DIET but I didn’t figure it out.

I had a look on udemy’s workshop repository and I saw that you used some kind of duckling.parser (I am not sure for the correct name), is this what you mean?

Ah, sorry for not being clear: that will be the data structure in the extracted entity. You can interact with it in a custom action using the SDK to get it from the Tracker using either get_slot or get_latest_entity_value).

To get DIET not to learn entities just don’t annotate them in your training data. You’ll still have them listed in your config file, you just don’t need to provide training data since they’re extracted using rules.