Reset specific slot values

Rasa Core version : 0.13.2

Python version : 3.6.8

Operating system : Windows

Issue: After filling the slots, the chatbot asks the user if all slots are filled out correctly. If the user responds with “no” or “its wrong”, the wrong slots have to be refilled.

Question: How can I reset a specific slot?

There are multiple similar questions to this, but I do not know how to apply it to my code:

Mainly they talk about the class ActionSlotReset(). But I do not know where to put it in my code. Maybe you can help me? Looking at my code, what excatly do I have to add in order to reset a specific slot (for example the slot contract_no)

My code:

stories.md

## story_greet_happy_path 
* greet
 - utter_introduction
 - utter_education  
> check_education   <!--- setting a checkpoint -->

## story_form_happy_path
> check_education
 - authenticate_form
 - form{"name": "authenticate_form"}   <!--- start form  --> 
 - slot{"name": "Sam Johns"}   <!--- asking for name  --> 
 - slot{"product": "credit"}    <!--- asking to choose a button  --> 
 - slot{"birthday": "01.01.1979"}  <!--- asking for birthday  --> 
 - slot{"contract_no": "123457890"}    <!--- asking for contract number  --> 
 - form{"name": null}    <!--- finish  form  --> 
 > check_summary

## story_summary
> check_summary
 - utter_summary_name
 - utter_summary_birthday
 - utter_summary_contract_no

## story_reset
* slot_incorrect
 - utter_reset_slot 
 - slot{"contract_no": "None"} 

train.md

## intent:slot_incorrect
- no
- this is wrong

domain.yml

utter_reset_slot:
   - text: "Your slot will be reseted now!"

actions.py

class AuthenticateForm(FormAction):
    """Example of a custom form action"""

    def name(self):
        # type: () -> Text
        """Unique identifier of the form"""
 
        return "authenticate_form"  

....



1 Like

You could do this in a CustomAction. You’d invoke this action at some point in your dialogue and put in the following in the “run” method of the action class:

class SampleAction(Action):
def name(self):
return ‘SampleAction’

 def run(self, dispatcher, tracker, domain):  
   ####some code or no code here
   return[SlotSet("Slot_to_be_reset_name", None")]

This is one way to do this.

5 Likes

If I do this (SlotSet in the return of the run function), in Rasa X / Talk to your bot part I can see the given slot as None or null (depending on how I set the value: None or “None”), but the slot is still there. Is there a way to delete in a way, that the slot “disappears”?

No, we cannot “delete” the slots while bot is running. We can just avoid using them.