Using Duckling HTTP Extractor for a data and time


I have realized that dates and times are hard. I saw that the duckling extractor finds a way to make this a lot easier. I have a forum that creates meetings and it currently checks for date and time entities to make sure it has all the information needed.

Since the duckling extractor does both date and time, how would I make sure that I am able to get both the needed pieces of information. When I try it currently with the duckling extractor applied, i would say " i would like to come in tomorrow" but the forum automatically stops because the extractor sees tomorrow but doesnt ask for a time. I need to be able to follow that message up with “What time are you looking to meet”.

Sorry if that sounded all over the place. If I need to clarify anything, please let me know!

Thank you!

Hey @abhi, you always want to get both date and time info, and the issue is that sometimes only one of these comes at first, right? I have to say that it’d be easier if Duckling could provide date and time separately, but it doesn’t…

What’s the exact output from Duckling when it extracts only date info but not time (as in your example)? I wonder if you could have a custom action that would check the extracted info and judge whether it’s both date and time or just one, and perhaps set separate data and time slots. Then, based on which slots are filled, next action could be chosen correctly (if you write stories/rules for this behaviour).

1 Like

Hey @SamS!

Yes, I would always need to get both the date and the time. In my example, it asks for date first if neither entities are detected in the create_meeting intent. When the bot asks what day would you like to come in, I say ‘tomorrow’. This extracts ‘2021-06-18T00:00:00:00’ and assigns it to the time entity (which autofills the time slot) and ends the form without asking for the time. So it captures the date properly but doesnt ask for the time.

How would you go about checking if the extracted info is both a time and day? My best idea would be to check if the time slot had the T00:00:00:00 and base it on that. Is that feasible?

Right, I get you @abhi. I have to say that checking for the T00:00:00:00 in a date-time extracted value is the only easy thing that comes to my mind. Indeed, this could backfire if the user actually specified that time in their utterance, but maybe you don’t expect that to happen in your scenario, or you could ask the user to confirm if unsure, or you could use some heuristics to make a reasonable guess, i.e. “did the user’s message contain the word midnight?”, etc.

1 Like

That makes sense. I will play around with it see if I can get that to work and also put in some safety in case someone chooses to have a meeting at midnight!

Thanks for your help!

1 Like