Use one question to fill two slots in rasa form action

I only know how to make a form that each question has 1 to 1 relationship to slot. For now, I have two questions: utter_ask_floor, which maps to floor slot, utter_ask_flat, which maps to flat slot. But, it would not be user friendly to always ask two question for two slots.

I want to have a question utter_ask_floor_and_flat that asks:

Which floor and flat are you living in?

and people can answer 18A (eg. [18](floor) [A](flat) )

So I want to have three questions, utter_ask_floor, utter_ask_flat, utter_ask_floor_and_flat.

In case one of the slots (floor or flat) is already filled, it will dispatch utter_ask_floor or utter_ask_flat as usual.

Because the advantage of form is that it can automatically ask questions if the slots are not filled but skip question if the slot is filled, I only want to ask utter_ask_floor_and_flat if only both floor and flat slots are not filled.

For example, if the user says “I want a food delivery”, utter_ask_floor_and_flat will be dispatched.

How can I achieve this?


1 Like

Hi @psfr937,

basically your FormAction takes Control over what is uttered. If everything is set as default, the 2 utterances for 2 slots logic will be executed.

To avoid that, meaning to allow e.g.:

a. I want a food delivery to 18A b. to 18 A

You have to ensure that:

a. Your stories allow mentioning of entities while triggering the action with *start_food_action{“floor”: “18”, “flat”: “A”} and other possible combinations

b. Your entities were learned correctly

c. Your Form action validation methods work accordingly:

If you want the form to ask for both parameters at once, you could overload the init method of your FormAction to utter your desired question or you could overload the validate function with the same. Asking for specific slots could be controlled in either validate or validate_param by following e.g. the example of ActionExecutionRejection .

Did that help? Tell me if you need more help.

I’m also facing the same problem, were you able to resolve this?