# Cannot handle unhappy path with form

**URL:** <https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210>\
**Category:** Rasa Open Source\
**Created:** [August 12, 2019, 5:00am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210 "2019-08-12T05:00:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TQuy](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tquy/32/3893_2.png) [@TQuy](https://forum.rasa.com/u/TQuy)\
**Post date:** [August 12, 2019, 5:00am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/1 "2019-08-12T05:00:24Z")

</div>

I want the bot to deactivate the form when the user want it to stop. I have been using interactive leanring to write stories about those but nothing works like suggestions. [stories.md](https://forum.rasa.com/uploads/short-url/mBxA6561aoX7rfgYDbDXIUODEnq.md) (2.0 KB) [actions.py](https://forum.rasa.com/uploads/short-url/mnTfNVaFbFF8NxMHBarsdlko8ml.py) (7.2 KB) [config.yml](https://forum.rasa.com/uploads/short-url/aTA30YzptLbJCPTDPL2gAomGaFe.yml) (534 Bytes) I found there are some topics the same as mine but none is solved

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [August 12, 2019, 6:13am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/2 "2019-08-12T06:13:34Z")

</div>

Hi @TQuy

have you tried the following inside your actions.py:

overwrite the validate-function (yes, **NOT** the validate\_{slots} one) inside your actions.py by including it. Then add the following lines to it:

```
    reset = self.check_reset_form_action_on_intent(tracker=tracker, dispatcher=dispatcher)
    if reset:
        return self.deactivate()

```

The method definition would look like:

```
@staticmethod
def check_reset_form_action_on_intent(tracker: Tracker, dispatcher):
    last_intent = tracker.latest_message['intent'].get('name')
    if last_intent == 'reset_dialogue':
        dispatcher.utter_message('Okay, what else can I do for you?')
        return True
    else:
        return False

```

All you need is to define a `reset_dialogue` intent which could be generally filled. Basically you would be able to reset every form action this way.

Did that work out for you?

Regards

---

<div class="post-metadata">

**Author:** ![TQuy](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tquy/32/3893_2.png) [@TQuy](https://forum.rasa.com/u/TQuy)\
**Post date:** [August 12, 2019, 6:53am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/3 "2019-08-12T06:53:03Z")

</div>

> [@JulianGerhard](#):
>
> function

I will try it but first I need to look for what validate-function is

---

<div class="post-metadata">

**Author:** ![TQuy](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tquy/32/3893_2.png) [@TQuy](https://forum.rasa.com/u/TQuy)\
**Post date:** [August 12, 2019, 7:16am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/4 "2019-08-12T07:16:10Z")

</div>

Thanks a lot. After finding the validate function you talk about, I understand more how the form work and being able to modify it. So if nothing was extracted by requested slot, reject excution of the form action. Consequently, I added additional condition in to `self.from_text(not_intent = 'deny')`. As a result, when intent `deny` is detected, the form will stop

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [August 12, 2019, 7:46am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/5 "2019-08-12T07:46:02Z")

</div>

Glad I could help!

---

<div class="post-metadata">

**Author:** ![kabeer](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kabeer/32/5310_2.png) [@kabeer](https://forum.rasa.com/u/kabeer)\
**Post date:** [May 20, 2020, 7:09am UTC](https://forum.rasa.com/t/cannot-handle-unhappy-path-with-form/14210/6 "2020-05-20T07:09:17Z")

</div>

@TQuyCan you post the solution which worked for you? And where can i find the `validate_function`.
