Dynamic forms: adding slot when intent appears

Hi everyone,

We are about to use dynamic forms in our chatbot. Before we start, I wanted to ask you guys a question: is there a way to add a slot if a certain intent appears?

Here’s the thing. Our dynamic form will be used to set an appointment. The user might ask to have a look at avaiable appointments from a certain date

“I want to set an appointment from 04/02/2021”

If this message appears in our form it will be classified in a specific intent and I want to add a slot in order to store the date “04/02/2021”. Is it possible?

Thanks, Andrea

Hi Andrea, this can be achieved by overriding the required_slots method as shown here: Forms. However, for the example you gave, I’m wondering why you would need to dynamically add slots? Because if the user doesn’t provide a date, wouldn’t that be valuable information that you’d want to ask them for? If so, it would be best to just define that slot in the domain. One of the features of forms is that if the user provides slot information even when that specific slot isn’t being asked for, that slot will still be filled.

Hi Alex

This is how we used to work. We are using Duckling for NER, and as far as “time” dimension is concerned in the italian language, Duckling tends to extract entities where there is no need to. We had no choice but deactivating the auto_fill in slots and use them only in forms :confused:

Of course, if you have an alternative option, we are open to suggestions! :smiley:

Andrea

Hi Andrea, have you considered conditioning on an intent in the validation function for the time slot? That way, the slot would only get set if the user actually wanted to set an appointment time.

Hi Alex,

Thanks for the suggestion! We actually do it already using the slot mapping. The problem is that slot mapping is impossible to do outside a form. If we didn’t have to use a form it would be easier :confused: Of course, I think this would be possible using a custom component