Clear the slots at the end of this conversation

In the forms, after filling in all the entities, end the dialogue, ask again how to make the entities empty and fill in again.

like this:
user: i want to order a hotel.
bot: please input the location.
user: *****
bot: please confirm the location : *****
user: Yes
bot: Finish!
user: i want to order a hotel.
bot: please confirm the location: ***** (Now it’s like this)
bot: please input the location. (i hope so)

Thanks.

you can create custom action for empty enetites and inside the action using SlotSet(“location”:None) you can empty the entites in slots

Thank you very much.

when using the SlotSet(“location”,None),the bot responds to me “please confirm the location: None”. I don’t hope the reply is None. How can I edit the custom formaction, please?

you can create a custom action that checks the value of slot (None or others) and based on it calls the next action i.e. if None is slot value then call ask location details, else ask to confirm.

@MagicMoGua can you paste your formaction here? It will be easy to understand then.

def required_slots(tracker): if getSlot(‘location’) and getSlot(‘affirm’): setSlot(‘location’,None) setSlot(‘affirm’,None) return [‘location’,‘affirm’]

Step 1:- First it checks the condition, that is whether the location and affirm slots are filled or not, if not it requests the user to fill location slot. Step 2:- Checks the condition, that is whether the location and affirm slots are filled or not, location slot already filled in the above step, now bot requests the user to fill affirm slot. Step 3:- This time it went through the condition because all slots filled and inside the condition, we are again assigning all slots values to none, because all slot values are None again it bot will request the user to fill slot values again.

This is my Formaction: class FormActionBookHotel(FormAction): def name(self): return “form_action_book_hotel”

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

    return ["location", "date"]

def submit(self, dispatcher: CollectingDispatcher, tracker: Tracker,
           domain: Dict[Text, Any], ) -> List[Dict]:

    return []

This is my one Story:

book_hotel

  • book_hotel
    • form_action_book_hotel
    • form{“name”: “form_action_book_hotel”}
    • form{“name”: null}
    • utter_confirm_hotel_values
  • confirm
    • utter_say_success

As I understand your formaction would look something like this.

class LocationConfirmationForm(FormAction):

    def name(self):
        return "location_confirmation_form"

    def required_slots(tracker):
        return [
            "location",
            "affirm",
        ]

    """Any slot mappings or validations you have"""

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:

        dispatcher.utter_message("Finish!")
        return [AllSlotsReset()]
        """instead you can use
        return{"location": None , "affirm": None}"""

Correct if i am wrong. But one of these 2 return commands inside your submit method will solve your problem.

I hope second one works. Did you try that?

Okay I did not see the the form action posted by @MagicMoGua and replied to @sravan2366. I am sorry.:smile:

@MagicMoGua You can try

or

in submit method. It will solve the issue.

Thanks everyone.
return [AllSlotsReset()],
return{“location”: None , “affirm”: None}
I tried the above ways.
e.g.
request two slots: location,time
utter_confirm_values: please confirm the values: location:{location} time:{time}
def submit():
dispatcher.utter_template(“utter_confirm_values”, tracker)
return[AllSlotReset()]
the result: please confirm the values: location:*** time:None
the reply I want: please confirm the values: location:*** time:***
this way is well: dispatcher.message(“please confirm the values: location:{} time:{}”.format(tracker.get_slot……))
I don’t know the reason.

@MagicMoGua that seems like your time slot is not filled. This information is not clear to identify the error. If you have given the time for asked question and still it is not identifying the time you can refer the log file to see whether the entity and slot has been identified correctly. If so that is something wrong with your formaction class. I suggest to refer logs and understand what is happening inside.

In case if you need `

rasa shell --log-file out.log --debug

is to activate logging in debug mode.

`