# Restart bot anytime

**URL:** <https://forum.rasa.com/t/restart-bot-anytime/15319>\
**Category:** Rasa Open Source\
**Created:** [September 6, 2019, 7:55am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319 "2019-09-06T07:55:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 6, 2019, 7:55am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/1 "2019-09-06T07:55:29Z")

</div>

Hi everyone. I have some issue with my bot. When user is in a formAction with some required slots. In there i cannot restart bot with '/restart '. How do i restart bot anytime if i want. Thank you so much

---

<div class="post-metadata">

**Author:** ![nbeuchat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nbeuchat/32/13688_2.png) [@nbeuchat](https://forum.rasa.com/u/nbeuchat)\
**Post date:** [September 6, 2019, 10:51am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/2 "2019-09-06T10:51:07Z")

</div>

The way I did it was to create a custom action `action_reset_full` which resets all slots, restart the conversation and turns off any form.

```
from rasa_sdk import Action
from rasa_sdk.events import Form, AllSlotsReset, Restarted

class ActionResetFull(Action):
    def name(self):
        return "action_reset_full"

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_template("utter_reset_full", tracker)
        return [Form(None), AllSlotsReset(None), Restarted(None)]

```

I also have an intent `reset` that triggers this action so that you can just type “Reset” and the whole thing starts over. In our domain, it would look like (in the `intents` section of `domain.yml`):

```
- reset:
    name: reset
    triggers: action_reset_full

```

Hope that helps! Nicolas

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 6, 2019, 11:29am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/3 "2019-09-06T11:29:35Z")

</div>

Thank you so much for reply. I will try it

---

<div class="post-metadata">

**Author:** ![nbeuchat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nbeuchat/32/13688_2.png) [@nbeuchat](https://forum.rasa.com/u/nbeuchat)\
**Post date:** [September 6, 2019, 1:37pm UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/4 "2019-09-06T13:37:41Z")

</div>

You’re welcome! Let me know if that works or if you have any issue

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 10, 2019, 3:36am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/5 "2019-09-10T03:36:22Z")

</div>

Hi Nicolas, sorry for the late reply.   
your code worked but some issues appeared  
because when user is in a formAction (some slots are filled and some slots are not filled)  
user cannot reset chatbot. All type of slot are unfeaturized and text.  
How can i reset chatbot anytime

Thank you so much,

---

<div class="post-metadata">

**Author:** ![nbeuchat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nbeuchat/32/13688_2.png) [@nbeuchat](https://forum.rasa.com/u/nbeuchat)\
**Post date:** [September 11, 2019, 1:07pm UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/6 "2019-09-11T13:07:47Z")

</div>

@vunt39 what happens when the user tries to reset the slots? How is the slot mapping of your forms?

For us, it usually works but we have some issues sometimes in forms (it’s quite erratic though).

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 12, 2019, 1:16am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/7 "2019-09-12T01:16:35Z")

</div>

here is the slot mapping

def slot\_mappings(self) -\> Dict[Text, Union[Dict, List[Dict]]]: return { # “cuisine”: self.from\_entity(entity=“cuisine”, not\_intent=“chitchat”),

```
        "lunch_time_string": [self.from_entity(entity="lunch_time_string"), self.from_text()],
        "lunch_select_kitchen": [self.from_entity(entity="lunch_select_kitchen"), self.from_text()],
    }
```

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 12, 2019, 1:20am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/8 "2019-09-12T01:20:23Z")

</div>

the slot mapping of my bot capture text message from user because there are many slot is number. for example lunch\_number\_slot is number, and lunch\_number\_people is a number too. so i cannot capture that slots in 1 or multiple intent. i capture that by self.from\_text(). i think it’s the issue

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 12, 2019, 4:29am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/10 "2019-09-12T04:29:12Z")

</div>

this is an idea of mine about that in file actions.py

def validate\_lunch\_select\_kitchen(  
self,  
value: Text,  
dispatcher: CollectingDispatcher,  
tracker: Tracker,  
domain: Dict[Text, Any],  
) -\> Any:  
print(value)  
if(value == ‘restart’):  
return [trackers(‘action\_reset\_full’)]  
if vali.validate\_kitchen(value):  
value = vali.return\_kitchen(value)  
return {“lunch\_select\_kitchen”: value}  
else:  
dispatcher.utter\_template(“utter\_wrong\_lunch\_select\_kitchen”,tracker)  
return{“lunch\_select\_kitchen”: None}

but it isn’t work.

---

<div class="post-metadata">

**Author:** ![nbeuchat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nbeuchat/32/13688_2.png) [@nbeuchat](https://forum.rasa.com/u/nbeuchat)\
**Post date:** [September 12, 2019, 8:11am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/11 "2019-09-12T08:11:34Z")

</div>

Two ideas:

- Do you have the `MappingPolicy` at the beginning of your `policies` in config.yml? Without it, the mapped triggers won’t work (and as far as I understand, this policy must be at the beginning of yourp policies)
- In the slot\_mapping, you can also explicitely ignore some intents. `self.from_text(not_intent=["reset"])` for example. That can also be achieved with stories I believe but it’s much more annoying to do.

On a side note regarding your numbers problem. We had a similar issue with number of bedrooms and number of bathrooms that could be specified in the same sentence. What I ended up doing was to create two entities `bedrooms_count` and `bathrooms_count` and added some training samples:

```auto
## intent:chose_apartment
- I need a [1](bedrooms_count) bed [2](bathrooms_count) bath apt
- Looking for a [one](bedrooms_count) bedroom flat
- ...

```

No idea if it’s best practice but that worked quite well with enough training samples as the `CRFEntityExtractor` would recognize that the number is followed by a specific word. Then, in our validation functions, we matched the number extracted by Duckling and the one extracted by the `bedrooms_count`/`bathrooms_count` entities.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 12, 2019, 3:14pm UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/12 "2019-09-12T15:14:24Z")

</div>

Hi nicolas. thank you for your reply. i think that knowledge help me very much. i will try it and then notify you about my result. thank you so much again

---

<div class="post-metadata">

**Author:** ![nbeuchat](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nbeuchat/32/13688_2.png) [@nbeuchat](https://forum.rasa.com/u/nbeuchat)\
**Post date:** [September 13, 2019, 8:16am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/13 "2019-09-13T08:16:21Z")

</div>

Very happy to help 🙂 Let me know how it goes!

---

<div class="post-metadata">

**Author:** ![vunt39](https://avatars.discourse-cdn.com/v4/letter/v/4bbf92/32.png) [@vunt39](https://forum.rasa.com/u/vunt39)\
**Post date:** [September 16, 2019, 6:56am UTC](https://forum.rasa.com/t/restart-bot-anytime/15319/14 "2019-09-16T06:56:31Z")

</div>

thank you nicolas that’s advice really really helpful to me. it’s worked. thank you so much
