# Reset Slot (FormAction)

**URL:** https://forum.rasa.com/t/reset-slot-formaction/552
**Category:** Rasa Open Source
**Created:** [August 20, 2018, 6:48am UTC](https://forum.rasa.com/t/reset-slot-formaction/552 "2018-08-20T06:48:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mjoellnier](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mjoellnier](https://forum.rasa.com/u/mjoellnier)
#### Post date: [August 20, 2018, 6:48am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/1 "2018-08-20T06:48:40Z")

</div>

Hey there!

I’m using `FormAction` to fill a bunch of slots. For all my 12 slots I’m using 3 FormActions. I’m asking myself if it’s possible to “reask” some slots which were already set by a FormAction when an user want so?

For example: during the conversation the Slot `userName` got filled and the user sees a typo in it. He wants to correct it by stating “Wait a second, I want to correct my username!” It would be perfect if the bot now resets the appropiate slot(s) and reasks them via the FormAction.

---

<div class="post-metadata">

### Author: ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://forum.rasa.com/u/momo)
#### Post date: [August 20, 2018, 2:54pm UTC](https://forum.rasa.com/t/reset-slot-formaction/552/2 "2018-08-20T14:54:12Z")

</div>

Hey,  
my first intuition would be to create an extra intent let’s say `change_slot` and two additional slots, which contain the name of the slot you want to change `changing_slot_name` and the value `changing_slot_value`. Then you add a custom actions which is triggered when your intent is recognized and tries to set the slot with `changing_slot_name` to `changing_slot_value`.  
Your stories would then look something like this (taken from the example stories in the docs):

```auto
...
* request_restaurant
     - action_restaurant_form
     - slot{"requested_slot": "people"}
* inform{"number": 3}
     - action_restaurant_form
     - slot{"people": 3}
     - slot{"requested_slot": "cuisine"}
* change_slot{"changing_slot_name": "people", "chaning_slot_value": 5}
    - action_change_slot
   - slot{"people": 5}
...

```

I’m by no means an expert, so this might not be helpful at all.  
Also I don’t think there is a build-in function for “re-asking” for FormActions, the only thing you could do is use the `validate()` function of FormFields to atleast catch “false” entries.

---

<div class="post-metadata">

### Author: ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)
#### Post date: [August 21, 2018, 9:30am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/3 "2018-08-21T09:30:31Z")

</div>

@momo Can you help me to this. Is it possible to set slot values for utter\_actions?

---

<div class="post-metadata">

### Author: ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://forum.rasa.com/u/momo)
#### Post date: [August 21, 2018, 1:04pm UTC](https://forum.rasa.com/t/reset-slot-formaction/552/4 "2018-08-21T13:04:45Z")

</div>

@raghavendrav1210 I’m not sure if I completly understand what you want to achieve. Do you want to set a slot when an utter\_action is called?  
If that in fact is what you want to do, I don’t think it’s possible, but it is also pretty simple to achieve that with a custom action, which would look something like thiat:

```auto
import ...

class ActionUtterAndSetSlot(Action:
    def name(self):
        return "action_utter_and_set_slot"

    def run(self, dispatcher, tracker, domain):
        your_slot_value = some_kind_of_request()
        dispatcher.utter_message("Your example Utterance")
        return [SlotSet("your_slot_name", your_slot_value)]

```

Hope this helps, feel free to ask again, if that’s not what you meant. 🙂

---

<div class="post-metadata">

### Author: ![mjoellnier](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mjoellnier](https://forum.rasa.com/u/mjoellnier)
#### Post date: [August 22, 2018, 9:37am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/5 "2018-08-22T09:37:04Z")

</div>

thanks for the idea @momo! Yes, I also thinked about this in a pretty similiar way. The only thing I’m struggenling with is the fact that I’m having ~20 Slots and I need a good way to distinguish between them when the Intent `change_slot` is recognized.

Maybe any idea from your side?

---

<div class="post-metadata">

### Author: ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)
#### Post date: [August 22, 2018, 9:50am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/6 "2018-08-22T09:50:21Z")

</div>

Thanks @momo it solves part of my problem. I have another question not related to this but can you help me to understand this. I’m always getting **next\_action** as **_action\_listen_**. Do you have any idea why?

---

<div class="post-metadata">

### Author: ![mjoellnier](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mjoellnier](https://forum.rasa.com/u/mjoellnier)
#### Post date: [August 22, 2018, 9:58am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/7 "2018-08-22T09:58:34Z")

</div>

Maybe I can help as well: it seems that this is a known problem as you can see on the GitHub isse I link below.

I also had this behaviour and was able to solve this with (a lot) more training stories. But there are still cases where I get this false behaviour

> <https://github.com/RasaHQ/rasa/issues/2335>
>
> Because generally the most commonly predicted action is ActionListen, when the b…ot is out of its comfort zone it may just predict ActionListen after a user utterance, which doesn't help the conversation move along. It should go to fallback policy in this case.
> Case when this should happen:
> 1. if there’s a fallbackpolicy present AND
> 2. if there was just a user message AND
> 3. the predicted action is action\_listen AND
> 4. it wasn't predicted by the memo policy

---

<div class="post-metadata">

### Author: ![raghavendrav1210](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/raghavendrav1210/32/2235_2.png) [@raghavendrav1210](https://forum.rasa.com/u/raghavendrav1210)
#### Post date: [August 22, 2018, 10:32am UTC](https://forum.rasa.com/t/reset-slot-formaction/552/8 "2018-08-22T10:32:40Z")

</div>

Thanks @mjoellnier

---

<div class="post-metadata">

### Author: ![momo](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@momo](https://forum.rasa.com/u/momo)
#### Post date: [August 22, 2018, 12:30pm UTC](https://forum.rasa.com/t/reset-slot-formaction/552/9 "2018-08-22T12:30:18Z")

</div>

@mjoellnier Yeah I was actually thinking about that when writing up my answer and don’t really have a solution.

But do you really have the need to distinguish them? Wouldn’t it be enough for the action to check if the the `slot_name` is in `tracker.slots` and if it is just set the slot to the aquired `slot_value`?
