Optional slots in Form Action

The default implementation of the Form Action mandates that all the fields listed in required_fields have to be filled before the submit method is triggered. But I have a slightly different scenario where submit can be triggered as long as some of the slots are filled. For ex: I have the following slots - city, state, country, category, product type. I just need one of city / state / country and one of category / product type to be filled before calling the submit method. I implemented a complicated way of doing it by making required_fields a list of lists as follows: [[city, state, category], [category, skills]] & checking if one slot in each of the list is filled. But is there a better way of implementing this? Any help would be appreciated

Basically I would make an option slot by doing this:

NOT adding it to required_slots

Adding it to slot_mappings

So if the slot is found on the text it would map anyway even when not required. But this would mean it would not ask for the slot. That means if you want to actively ask for it. The best way would be to put it on required_slots and give an “skip” option. It could be a quick-reply for example.

In your case specific case I would do one of the following:

Put everything on required and slotmapping. Add “request_next_slot” and “validate” to the method. On request_next_slot, I would check if at least one of the city/state/country was mapped if yes I would pass in the return: return [SlotSet(REQUESTED_SLOT, slot)] where “slot” would be equal to category or product. Otherwise if category or product was also filled you would return None


Hi @Sekhar-jami can u explain more on how to implement optional slots using your approach list of lists…In my case i just want to check for 2 slots (account number/trans ID)…so i feel your approach will do the job for me.

Hi @Sekhar-jami ,

there are several ways to achieve this @custodio suggests a working example. For the sake of simplicity and if there is no need to validate the slots through the FormAction validators, you could also use a CustomAction instead of a FormAction by using:

pack_location = ['city', 'state', 'category']
for loc in pack_location:

So you just would have to decide when to trigger whatever is triggered in your previous submit method.