Value of Slot getting overwritten

Hello Everyone,

Iam facing a peculiar issue while using two slots, which will contain numeric value. My chatbot asks for height and age in the form. When user enters height as 6 and age as 23 then both slots get same value i.e 23.

I had noticed that in case one slot takes numeric value and other takes text value then this behavior is not observed.

Any clues on what the issue could be and how to solve this.

Here is what is happening ->

Your input ->  hi
Bot -> Hey! Iam a health chatbot! To get started enter your height and age.
Your input ->  my height is and age is
Bot -> Please enter your height
Your input ->  4
Bot -> Please enter your age
Your input ->  12
Bot -> Your height is 12, age is 12. You are healthy !!

Nlu ->

## intent:inform
- [2](height)
- [3](height)
- [4](height)
- [5](height)
- [6](height)
- [7](height)
- [23](age)
- [42](age)
- [34](age)
- [45](age)
- [23](age)

## intent:take_order
- Iam [3](height) feet tall
- my age is [13](age) 
- Iam [3](height) feet tall and my age is [13](age)
- Iam [4](height) feet tall and my age is [18](age)
- Iam [5](height) feet tall and my age is [23](age)
- Iam [6](height) feet tall and my age is [28](age)

Domain ->

- take_order
entities:
- height
- age
slots:
  height:
    type: unfeaturized
  age:
    type: unfeaturized
responses:
  utter_greet:
  - text: Hey! Iam a health chatbot! To get started enter your height and age.
  utter_goodbye:
  - text: Bye
  utter_ask_height:
  - text: Please enter your height
  utter_ask_age:
  - text: Please enter your age
actions:
- action_today
forms:
- take_order_form

actions ->

class TakeOrderForm(FormAction):
    def name(self) -> Text:
        return "take_order_form"

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

    def slot_mappings(self) -> Dict[Text, Any]:
        """A dictionary to map required slots to
            - an extracted entity
            - intent: value pairs
            - a whole message
            or a list of them, where a first match will be picked"""

        return {
            "height": self.from_entity(entity="height"),
            "height": [self.from_text(intent=["take_order","inform"])],
            "age": self.from_entity(entity="age"),
            "age": [self.from_text(intent=["take_order","inform"])],         
               }
        
    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        """Define what the form has to do
            after all required slots are filled"""
          
        # get value of original intent from slot
        height = tracker.get_slot("height") 
        age = tracker.get_slot("age")        

        dispatcher.utter_message(text= "Your height is " + height + ", age is " + age + ". You are healthy !!")

This seems to be a bug in Rasa, I had been struggling from last few days, if anyone has any idea do share with me please.

Hi, this is actually a feature of Rasa. In order to get the behavior you expect, you’ll need to set auto_fill: false for each of those slots. That way they will only be filled as part of the form.

Another thing I noticed is that the age and height entities have overlap, e.g. 64 could be an age or a height. You should probably combine these into a single entity, “number”. Then map these to their respective slot values through the form.

2 Likes