Last slot returned from Form return None value although it's filled - Rasa Open Source - Rasa Community Forum

👋 Introducing the Rasa Playground

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

post by lupasten on Dec 24, 2019

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.

post by fuih on Dec 24, 2019

Hello @lupasten,

Can you provide more specific information, such as:

post by lupasten on Dec 26, 2019

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":
                 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}

# Other validation functions follow a similar structure...

Submit Function

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

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 because the validate function, I tried changing the value of else condition for another thing and it still shows “None”. Thanks for helping me

post by fuih on Dec 26, 2019

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!