# Custom actions in Forms

**URL:** <https://forum.rasa.com/t/custom-actions-in-forms/27332>\
**Category:** Rasa Open Source\
**Created:** [April 10, 2020, 8:41pm UTC](https://forum.rasa.com/t/custom-actions-in-forms/27332 "2020-04-10T20:41:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taimoor-ahmed](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/taimoor-ahmed/32/4108_2.png) [@taimoor-ahmed](https://forum.rasa.com/u/taimoor-ahmed)\
**Post date:** [April 10, 2020, 8:41pm UTC](https://forum.rasa.com/t/custom-actions-in-forms/27332/1 "2020-04-10T20:41:06Z")

</div>

Hi, I have created a form and it fills in slots as it should when it correctly recognizes the entity but throws an error when the bot is unable to extract the location entity. What I want to do then is ask the location again inside the form and extract the complete text string because I am assuming that the user will respond with the location only.

The domain file is:

> intents:
> 
> - emergency: use\_entities: 
> - greet
> - inform
> - thankyou
> - goodbye
> - chitchat
> 
> entities:
> 
> - etype
> - people
> - location
> 
> slots: etype: type: unfeaturized auto\_fill: false people: type: unfeaturized auto\_fill: false location: type: unfeaturized auto\_fill: false
> 
> responses: utter\_ask\_etype: - text: “ہادثہ کی نوعیت کیا ہے” utter\_ask\_people: - text: “کتنے افراد متاثر ہیں” utter\_ask\_location: - text: “کہاں ہادثہ پیش آیا ہے”

I need to know where I can add code so that after utter\_ask\_location, I can check if the location slot was filled correctly and if not, utter another template and fill the location with the subsequent response from the user.

---

<div class="post-metadata">

**Author:** ![samscudder](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/samscudder/32/4466_2.png) [@samscudder](https://forum.rasa.com/u/samscudder)\
**Post date:** [April 13, 2020, 1:56pm UTC](https://forum.rasa.com/t/custom-actions-in-forms/27332/2 "2020-04-13T13:56:51Z")

</div>

You can add a `validate_location` method in the form class, with something like this:

```auto
    def validate_location(self,
        value: Text,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> Dict[Text, Any]:

        # put your tests here

        # if value is not valid, return this:
        return {"location": None}

        # if value is valid, return this:
        return {"location": value}

```

If the location slot is still empty, Rasa will perform the `utter_ask_location` again.
