How to set several slots in a Form Action using the same entity?

Something weird happens when I run “rasa shell.” The first slot that is filled using the entity “number” is set, but all the slots afterward that should also be filled using the entity “number” are skipped. My suspicion is that the FormAction (onboarding_user_form) isn’t defined properly. I’ve not been able to get past this first FormAction so no need to look further then that. Any help is greatly appreciated.

actions.py (4.7 KB) domain.yml (3.3 KB) stories.md (942 Bytes) nlu.md (1.8 KB)

Hi Alex,

You’ll need to set the slots to auto_fill: false in your domain.yml file, e.g.:

  child_age:
    type: unfeaturized
    autofill: false

However, I believe the FormAction class by default tries to auto-fill slots based on entities and intents (depending on how you set up the slot_mappings method) without respecting the autofill:false clauses in the domain.yml. You can override this behavior by modifying the validate method to remove the call to extract_other_slots:

@overrides
    async def validate(
        self,
        dispatcher: "CollectingDispatcher",
        tracker: "Tracker",
        domain: Dict[Text, Any],
    ) -> List[EventType]:
        
        # slot_values = self.extract_other_slots(dispatcher, tracker, domain)
        
        slot_values = {}
        # extract requested slot
        slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
        if slot_to_fill:
            slot_values.update(self.extract_requested_slot(dispatcher, tracker, domain))

        logger.debug(f"Validating extracted slots: {slot_values}")
        return await self.validate_slots(slot_values, dispatcher, tracker, domain)
1 Like

Hi Will,

Thanks for your response; I set the slots to auto_fill: false and copied the validate method that you provided to my FormAction. However, it didn’t change the output of rasa shell. I also tried it without the @overrides since I was getting NameError: name 'overrides' is not defined.

Here are my updated files: actions.py (5.4 KB) domain.yml (3.6 KB) stories.md (1.2 KB) nlu.md (1.9 KB)

I was able to get this to run and not auto-fill the slots, using the above files by removing the line that references the logger line from the validate function as this is not imported into the actions.py file. This was causing an import error. If you run into any more trouble while testing, please provide the output of both:

rasa shell --debug

and

rasa run actions --debug

I removed the logger line as you suggested, and also tried running it both with and without auto-filling, but am still having the same issue. I’ve attached the Terminal output when I run rasa shell --debug and rasa run actions --debug. As you can see, the third and fourth slot are automatically being filled with the entity that is extracted for the second slot; so the third and fourth questions are skipped. Also I am still getting NameError: name 'overrides' is not defined.

output.txt (27.7 KB)

You need to include from overrides import overrides to the top of your actions.py file as you previously mentioned. Otherwise, your action server will continue to fail.

@kearnsw.

Thank you very much for the solution.

Thank you for the suggestion, I am also facing similar issues. But as per the above suggestion (auto_fill: False) , Bot prompting to enter each slot value, not picking any value from entities. My example is like :—

Show me some properties with 2 to 3 bedrooms between 2500 sqft and 3500 sqft and price between $2750000 to $3000000 in Washington, DC 20008

My training data are like this

Show me some properties with [2](unitsizemin) to [3](unitsizemax) bedrooms between [2500](minarea) sqft and [3500](maxarea) sqft and price between $[2750000](minprice) to $[3000000](maxprice) in [Washington](city), [DC 20008](locality)

Please suggest how to solve such long questions.

@Shaan27 I would suggest using only one entity, such as number. And then use roles to train your NLU model (Introducing Entity Roles and Groups). I suspect your entities aren’t being extracted because the NLU model can’t differentiate between all those different numbers.

2 Likes