Can I reset the value of all slots everytime before the form action

My bot has a form “account_form” and it is called after the intent “check_acc_detail” . After all required slots are filled, the expected response is got. I would like to keep the slot values for other intents except “check_acc_detail”. That means when any other intents are classified, the slot values are kept and used. If “check_acc_detail” is classified, the slot values are cleared and form action takes place.

I tried to add “form{“name”: null}”/action_restart in the stories the behaviour is unexpected.

the expected response is got.

What do you mean by that?

How about running an action right after check_acc_detail to unset the slots?

Sorry for the unclear words.

I mean that the form action works well for the first time. But if I want to run the form action again with restart, since the slots are already filled, the bot won’t ask me to input again.

I have already run the action right after check_acc_detail

.

This is my part of my story:

* check_acc_detail
  - account_form
  - form{"name": "account_form"}
  - form{"name": null}
  - utter_anything_else

I solved it by writing a custom action which resets all slots and then calling this action before activating the form in stories. like so:

class ActionResetAllSlots(Action):

    def name(self):
        return "action_reset_all_slots"

    def run(self, dispatcher, tracker, domain):
        return [AllSlotsReset()]

In story:

* check_acc_detail
    - action_reset_all_slots
    - account_form
    - form{"name": "account_form"}
    - form{"name": null}
    - utter_anything_else

Thank you for your reply.

I tried your method and add - action_reset_all_slots in the stories.

This method resets all slots before the form action, but autofill of the sentence used for intent classification does not work anymore as well.

If I type “What is the balance of my ABC bank account?”, autofill of {“bank”: “ABC Bank”} fails as this slot is reset.

Is there any solution that can reset all slots if check_acc_detail is classified again while the autofill is still available?

This is an example:

After the first form action, the slot set becomes:

- Current slot values: 
	bank: KING Bank
	time: ['last month', '2019-10-01T00:00:00.000+08:00']
	account_number: 123456
	requested_slot: None

If I type “What is the balance of my ABC bank account?” afterwards, my expected slot set would be:

- Current slot values: 
	bank: ABC Bank
	time: None
	account_number: None
	requested_slot: time

Hi, I’m not sure if I understand your problem correctly, but if you want to reset all slots except a few slot, you can do that in the custom action itself. Like so:

class ActionResetAllButFewSlots(Action):

	def name(self):
		return "action_reset_all_but_few_slots"

	def run(self, dispatcher, tracker, domain):
		bank = tracker.get_slot('bank')
		return [AllSlotsReset(), SlotSet("bank", bank)]

In story:

* check_acc_detail
    - action_reset_all_but_few_slots
    - account_form
    - form{"name": "account_form"}
    - form{"name": null}
    - utter_anything_else

This will first reset all the slots and then set the slot 'bank' to whatever the user had said. You can set multiple slots if required. Hope that helps.

Thank you Saurabh.

This solution is not work for my problem. I want to reset all slots if the form action while autofill of form action can still be working.

The reason to do so is that when I want to check acc detail and call the form action in the first time, all slots are filled with some values. However, if I classify the same intent check_acc_detail again to check for another account, I need to reset all slot value. Otherwise, the bot will not ask me to input any information but take the old slot value.

As we know, the form action can fill the required slots automatically if entities are extracted from my input. For example, if I type “I want to check my KING Bank account detail”, the bot returns intent: check_acc_detail and entity: {bank: KING Bank} and fill the slot bank with value “KING Bank”.

My problem is that if I reset all slot value before the form action takes place, the above behavior will not work anymore as the new slot value is also reset.

When I type “I want to check my KING Bank account detail”, the slot set becomes:

- Current slot values: 
	bank: None
	time: None
	account_number: None
	requested_slot: bank

which the bank’s value is None now but I would like it to be KING Bank.

Hello,

Did you find a solution for this? I need to follow a similar logic to yours and I’m facing the same problem while resetting the slots