Changing Form output based on slots

Hi all, I am fairly new here so I hope its not a stupid question:

I wanted to personalize my form action (that works just as intended) to output different utterances based on one of the required slots and also change on of the slots in the process. I put it into the submit function of the form, but it just gets ignored. This is the submit part:

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

    # utter submit template, based on emotion slot
    emo = tracker.get_slot("emotion")
    if emo in ["anger", "disgust"]:
        msg1 = "outter_confirm_order_angry"
    else: msg1 = "utter_confirm_order"

   # add the right "article" in front of location
   place = tracker.get_slot("LOCATION")
   myList = ["my", "our"]
   if any(x in place for x in myList):
       place = place.replace("our", "your" )
       place = place.replace("my", "your")
   else:
       place = "the "+place

   SlotSet("LOCATION", place)
   dispatcher.utter_message(template = msg1)
   return []

Any help is greatly appreciated! :slight_smile: To be clear, I get the Output “utter_confirm_order” even when the emotion is “angry” and the “LOCATION” remains unchanged.

Hi @Jessi,

Welcome to Rasa Community!

you need to return the SlotSet, In that way it will update the slots as well as tracker return[SlotSet("LOCATION", place)]

In the if condition you are checking for anger when the input is angry. In that case angry cannot match and it will jump to else part that’s why its printing utter_confirm_order

1 Like

Thanks for the reply!

I added the slot in the return, and it showed me that it set the slot correctly. This made me realize my error was putting it into the submit function, that way still the old slot was used for the utterances. I made a validate_LOCATION function with the same Code and now it works! :slight_smile: