Last slot returned from Form return None value although it's filled

Hey guys, I have a problem with a project that I’m doing on rasa. I’m trying to fill a few slots in a Form of rasa, for this i’m following the example Formbot of Rasa’s github. The fill of the slots results perfectly but at moment of send this information and show it by the submit part of Form using a Dispatcher.utter_message (template = “utter_slots”) that shows the values ​​of the every slots, the last slot appears with value “None”, although the slot was validate previously. I don’t find the reason why is this happening, please help.

Hello @lupasten,

Can you provide more specific information, such as:

  • How do you define the slots ?
  • What’s the utter template like ?
  • How is the slot validated ? (maybe post the validate function if you can)
  • What’s the submit function of the form like ?

Definition of slots:

slots:
  queso:
    type: text
    auto_fill: false
  peperoni:
    type: text
    auto_fill: false
  salame:
    type: text
    auto_fill: false
  choclo:
    type: text
    auto_fill: false
  pollo:
    type: text
    auto_fill: false
  tocino: 
    type: text
    auto_fill: false
  champinon: 
    type: text
    auto_fill: false
  requested_slot:
    type: unfeaturized

Utter templates:

templates:
  utter_greet:
  - text: "Hola, bienvenido"

  utter_ask_queso:
  - text: "Desea queso en su pizza?"

  utter_ask_peperoni:
  - text: "Desea peperoni en su pizza?"

  utter_ask_salame:
  - text: "Desea salame en su pizza?"

  utter_ask_choclo:
  - text: "Desea choclo en su pizza?"

  utter_ask_pollo:
  - text: "Desea pollo en su pizza?"

  utter_ask_tocino:
  - text: "Desea tocino en su pizza?"

  utter_ask_champinon:
  - text: "Desea champiñon en su pizza?"

  utter_wrong_option:
  - text: "Debe ingresar si desea o no desea el ingrediente, intentelo nuevamente"

  utter_como_puedo_ayudarte:
  - text: "¿Como puedo ayudarte?"

  utter_slots:
  - text: "La pizza será preparada con los siguientes ingredientes: \n
          Queso: {queso}\n
          Peperoni: {peperoni}\n
          Salame: {salame}\n
          Choclo: {choclo}\n
          Pollo: {pollo} \n
          Tocino: {tocino} \n
          Champinon: {champinon} \n
          Confirma el pedido? "

  utter_estoy_en_ello:
  - text: Estamos preparando tu pizza, tu pizza estará lista en 80 min y será enviada por rappi ;)
  utter_ingrediente_extra:
  - text: Deseas agregar algún otro ingrediente?

Validation of Slots:

         def validate_queso(
                 self,
                 value: Text,
                 dispatcher: CollectingDispatcher,
                 tracker: Tracker,
                 domain: Dict[Text, Any],
             ) -> Dict[Text, Any]:
                 if value.lower() == "si":
                     print("hola")
                     return {"queso": value}
                 elif value.lower() == "no":
                     return {"queso": value}
                 else:
                     dispatcher.utter_message(template="utter_wrong_option")
                     return{"queso": None}     

    def validate_peperoni(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"peperoni": value}
        elif value.lower() == "no":
            return {"peperoni": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"peperoni": None}     

    def validate_salame(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"salame": value}
        elif value.lower() == "no":
            return {"salame": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"salame": None} 

    def validate_choclo(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"choclo": value}
        elif value.lower() == "no":
            return {"choclo": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"choclo": None} 

    def validate_pollo(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"pollo": value}
        elif value.lower() == "no":
            return {"pollo": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"pollo": None} 

    def validate_tocino(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"tocino": value}
        elif value.lower() == "no":
            return {"tocino": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"tocino": "None"} 

    def validate_champinon(
        self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> Dict[Text, Any]:
        if value.lower() == "si":
            return {"champinon": value}
        elif value.lower() == "no":
            return {"champinon": value}
        else:
            dispatcher.utter_message(template="utter_wrong_option")
            return{"champinon": None}

Submit Function

def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        print("****************SUBMITE*****************")
        dispatcher.utter_message(template="utter_slots")
        return[]

here is when the bot start to ask if the customer wants a specific ingridient and he need to answer with “si” or “no” (yes or no)

When running rasa at debug form show that all the slots are filled but when i show it by utter template, always the last slot filled shows “None” value. This isn’t becouse the validate function, i tried changing the value of else condition for another thing diferent like “JAJA” and shows anyway “None”.

Thanks for helping me

@lupasten

First of all, if those slots are only used in the form any not in the stories, you should change their type to “unfeaturized” since you don’t want them to impact the stories.

Second, can you put these lines in your submit function and run it again to see if the “tocino” slot is actually set before the form end ?

tocino = tracker.get_slot("tocino")
print("The value for Tocino slot is:", tocino)

Check the console to see the tocino slot’s value.

Hi @fuih, I changed the type of the slots to unfeaturized, but it wasn’t the problem. Also i putted those lines in submit function and when i run it the value of tocino is the i answer it when the Bot ask me.
image

And still showing this

I hope we can find the solution.

@lupasten

All right, so the slot is definitely set correctly. At this point the only thing i can think of is something wrong with the utter template, is there a chance that you change it but forget to train the model again ? Try this in your submit function, if this doesn’t work then maybe try training the model again.

tocino = tracker.get_slot("tocino")
dispatcher.utter_message(template="utter_slots", tocino=tocino)

Thanks @fuih sending directly the value by the dispatcher show the real value and no the “None” value, Thanks for your help! :smiley:

Hi, i am having the same issue. Although your solution works but why do we need to explicitly give slot value to utter_message method in submit method ? I have two forms, one form’s last slot works perfectly fine in domain utter_message but other form has this issue.