# Best approach to handle Fallback at any stage and trigger an action

**URL:** <https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958>\
**Category:** Rasa Open Source\
**Created:** [March 11, 2020, 8:51pm UTC](https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958 "2020-03-11T20:51:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cheer](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cheer](https://forum.rasa.com/u/cheer)\
**Post date:** [March 11, 2020, 8:51pm UTC](https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958/1 "2020-03-11T20:51:10Z")

</div>

What is the best approach to handle Fallback at any stage and trigger an action. Two-stage Fallback Policy seems like an over kill when all I want to do is trigger an utter and ask for using to fill a contact form.

I have seen a lot of examples but nothing with such scenario. Maybe I missed it. It would be great if someone can answer or point me to the right resource.

---

<div class="post-metadata">

**Author:** ![saurabh-m523](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/saurabh-m523/32/7887_2.png) [@saurabh-m523](https://forum.rasa.com/u/saurabh-m523)\
**Post date:** [March 12, 2020, 3:31am UTC](https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958/2 "2020-03-12T03:31:30Z")

</div>

How about using the simple [`Fallback Policy`](https://rasa.com/docs/rasa/core/fallback-actions/#fallback-policy)?. Here you can define your custom action/utter which will be triggered on Fallback.

---

<div class="post-metadata">

**Author:** ![cheer](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cheer](https://forum.rasa.com/u/cheer)\
**Post date:** [March 12, 2020, 11:42am UTC](https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958/3 "2020-03-12T11:42:49Z")

</div>

Thanks that’s what I am using. But this won’t work as intended

```
class ActionDefaultFallback(Action):
def name(self) -> Text:
    return "action_default_fallback"

def run(self, dispatcher, tracker, domain):
    logger = logging.getLogger( __name__ )
    dispatcher.utter_message(template="utter_default")

    if tracker.active_form.get("email_id") is not None:
 
        dispatcher.utter_message(template="utter_additional_question_response")
    else:
        dispatcher.utter_message(template="utter_test")

    return [AllSlotsReset(),UserUtteranceReverted()]
```

---

<div class="post-metadata">

**Author:** ![cheer](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@cheer](https://forum.rasa.com/u/cheer)\
**Post date:** [March 12, 2020, 12:45pm UTC](https://forum.rasa.com/t/best-approach-to-handle-fallback-at-any-stage-and-trigger-an-action/25958/4 "2020-03-12T12:45:59Z")

</div>

If this can help someone in near future. solution. Not perfect though.

```
class ActionUtterNext(Action):
def name(self) -> Text:
    return "action_utter_next"
def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    emails = tracker.get_slot("email_id")
    dispatcher.utter_message("Thank you ! You will soon receive an email from us at {}".format(emails))

    return [AllSlotsReset(),UserUtteranceReverted()]

```

class ActionDefaultFallback(Action): def name(self) -\> Text: return “action\_default\_fallback”

```
def run(self, dispatcher, tracker, domain):
    logger = logging.getLogger( __name__ )

    emails = tracker.get_slot("email_id")
    print(emails)
    if emails is not None:
        # dispatcher.utter_message(template="utter_additional_question_response")
        return [FollowupAction("action_utter_next")]
    else:
        dispatcher.utter_message(template="utter_default")
    return []
```
