Validation of Form Input validates twice

Hello everybody,

I’ve got the following issue: I created a Validation-Method for one of my Form-Slots, so that the slot person_name would be validated. The Problem is that it is validated twice and so the messages in the validation method are also uttered twice.

Where is the problem? Why is Rasa running the validation twice and how can I avoid this. Many thanks for your help in advance.

class PersonForm(FormAction):
    """Custom form action to fill all slots required to find specific type
    of a subject itself or an abbreviation"""

    def name(self) -> Text:
        """Unique identifier of the form"""

        return "person_form"

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        """A list of required slots that the form has to fill"""

        return ["person_name", "person_attribute"]

    def slot_mappings(self) -> Dict[Text, Any]:
        return {"person_name": self.from_entity(entity="person_name",
                                                intent=["inform_person_name",
                                                        "search_person"]),
                "person_attribute": self.from_entity(entity="person_attribute",
                                                     intent=["inform_person_attribute",
                                                             "search_person"]),
                }

    def validate_person_name(
            self,
            value: Text,
            dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        """Validate person_name value."""

            # Query DB for all persons
            results = query_database_all("person_name", "persons", "", "")
            # Create empty set for synonym sounding person names
            synonyms = []
            # check for each person
            for result in results:
                # if name is similar to the asked person name with Levenshtein Distance
                if fuzz.ratio(value, result[0]) > 80:
                    # Add Name to the set
                    synonyms.append(result[0])
            # Check if we found a similar name
            if synonyms:
                if len(synonyms) == 1:
                    # Change Name of Person
                    person_name = synonyms[0]
                    # Validation runs twice because new entity is provided, so message would be shown twice
                    # dispatcher.utter_message(text="Du meinst bestimmt {}.".format(person_name))
                    return {"person_name": person_name}
                else:
                    # buttons = []
                    # for person in synonyms:
                    #    buttons.append({"title": person, "payload": person})
                    # dispatcher.utter_message(text="Wen meinst du genau? Ich kenne:", buttons=buttons)
                    dispatcher.utter_message(text="Wen meinst du genau? Ich kenne:")
                    for person in synonyms:
                        dispatcher.utter_message(text=person)
                    return {"person_name": None}

            # ... nobody found
            else:
                dispatcher.utter_message(text="Leider weiß ich nichts über {}.".format(value))
                return {"person_name": None}
        else:
            return {"person_name": value}

Just to check, what version of Rasa/python are you running? Can you also give an example of a chat that is interacting with this form?

Hi Vincent,

I’m running Rasa 1.9.4 and Python 3.7.7.

Here is a Chat-Example:

I could be wrong, but it seems like this issue is also mentioned here.

One thing that might be worth a try, could you try updating Rasa? It might be a bug that was fixed in Rasa 1.10.