Problem using forms

When using forms in Rasa, there is a method in the FormAction class where values other than the requested slot are extracted. It´s called extract_other_slots and it is invoked from the validate method(348-350):

#extract other slots that were not requested
#but set by corresponding entity or trigger intent mapping
slot_values = self.extract_other_slots(dispatcher, tracker, domain)

In extract_other_slots, the required slots are obtained and checked if they have to be filled. There are two checks to fill the slot - if the slot should be filled by entity or by trigger intent. The check if the slot should be filled by entity is the following:

//check whether the slot should be filled
// by entity with the same name
should_fill_entity_slot = (
            other_slot_mapping[“type”] == “from_entity”
            and other_slot_mapping.get(“entity”) == slot
            and self.intent_is_desired(other_slot_mapping, tracker)

I didn´t understand why the slot is going to be filled only by entities with the same name. Why do not fill the slots from entities with different names?

The effect is:

  • A form has a slot called “parameter” that is mapped to two entities - name or number
  • The required slots are [parameter, confirmation]
  • The user enters a number, the slot “parameter” is filled and the next requested slot is confirmation
  • When the user is asked for confirmation, he/she changes his/her idea and enter a name.
  • The active form is runned, it tries to fill the confirmation slot without success.
  • The required slot at this point is “confirmation”. But the slot “parameter” is pointing to the old number. The form executes the method extract_other_slots, but does not update the “parameter” slot, because of the check above (the slot has to have the same name as the entity)
  • The form asks for the confirmation to the user with the number instead of showing the name that the user entered.

I think this is a bug. But some people disagree.

What do you guys think?

what if you have two different slots, e.g. number_of_people and number_of_days, both should be set by the same entity number. If the slot is requested then we know to which slot ambiguous entity corresponds, however in extract_other_slots method, we try to fill any slot. In this case if entity number is extracted there is no way of knowing if it should fill number_of_people or number_of_days.

The fact that in you case there is a unique slot is just a special case. FormAction is fully customizable so you can simply override this behavior in your custom subclass.

We solved the problem overriding the method extract_other_slots. But I wanted to understand why the implementation is like that, always with the will to improve Rasa.

The scenario that you brought could be solved by controlling the requested slots, that is if you have ambiguity in your slots, you can have between your requested slots only one that is mapped to an specific entity. So, if you have number_of_people and number_of_days, one should be required after the validation of the other. You would not have two required slots from the same entity at the same time. This could be easily done without customization if the extract_other_slots had different implementation. So, in both scenarios (mine and yours), a customization is necessary. The current implementation only fullfill the case when the slot and entity have the same name.

Since in our business having slots with the same name as the entity is an exception (the slot is usually the business role the entity plays), we will maintain this customization as default for our rasa implementations.

Thank you very much!