# Rasa is not triggering the custom form action

**URL:** <https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618>\
**Category:** Rasa Open Source\
**Created:** [July 11, 2021, 10:35pm UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618 "2021-07-11T22:35:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![travelmail26](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/travelmail26/32/9388_2.png) [@travelmail26](https://forum.rasa.com/u/travelmail26)\
**Post date:** [July 11, 2021, 10:35pm UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618/1 "2021-07-11T22:35:48Z")

</div>

I’m creating a survey bot in Rasa and I’d like it to trigger a function in the actions.py file when it receives a response on one of the form slots. I tried following the instructions for the `extract_` slot method in the documentation, but something isn’t working. Here is my code from the domain and actions (the function in actions that it should trigger is `list_tasks_numbered_names` when the experience\_dose slot is filled).

So long as I fill the appropriate intents, the form continues filling the slots, but it just doesn’t trigger anything in actions.py

Thank you and please let me know if I can make this question more clear

ACTIONS

```
class ValidateExperienceForm(FormValidationAction):
    def name(self) -> Text:
        print ('experiece form triggered')
        return "validate_experience_form"
    

    async def required_slots(
        self,
        slots_mapped_in_domain: List[Text],
        dispatcher: "CollectingDispatcher",
        tracker: "Tracker",
        domain: "DomainDict",
    ) -> Optional[List[Text]]:
        required_slots = slots_mapped_in_domain
        return required_slots

    async def extract_experience_dose(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> Dict[Text, Any]:
        print ('experiece form triggered under async')
        text_of_last_user_message = tracker.latest_message.get("text")
        
        tasklist = list_tasks_numbered_names(text_of_last_user_message)

        #tasklist = '"' + tasklist + '"'
        resp = "Here is your task list: \n"+str(tasklist)
        
        print ('DEBUG: this is the task list', tasklist)
        
        
        
        #dispatcher.utter_message('here is a list of tasks to choose from', tasklist)
        dispatcher.utter_message(resp)
        return [SlotSet('experience_dose', tasklist)]

```

DOMAIN

```
experience_form:
    required_slots:
      experience_substance:
      - type: from_text
        not_intent: bogusintent
        value: false
      experience_dose:
      - type: from_text
        not_intent: bogusintent
        value: true
      experience_insight:
      - type: from_text
        intent: inform
        value: true
```

---

<div class="post-metadata">

**Author:** ![Dustyposa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/dustyposa/32/13745_2.png) [@Dustyposa](https://forum.rasa.com/u/Dustyposa)\
**Post date:** [July 12, 2021, 2:32am UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618/2 "2021-07-12T02:32:29Z")

</div>

DId you add `validate_experience_form` into `domain.yml -> actions` ?

---

<div class="post-metadata">

**Author:** ![travelmail26](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/travelmail26/32/9388_2.png) [@travelmail26](https://forum.rasa.com/u/travelmail26)\
**Post date:** [July 12, 2021, 5:43pm UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618/3 "2021-07-12T17:43:20Z")

</div>

Very helpful! It’s triggering the action.py, but it’s running the entire function for every slot. How do I just run the function for this specific slot step? Thank you!

---

<div class="post-metadata">

**Author:** ![Dustyposa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/dustyposa/32/13745_2.png) [@Dustyposa](https://forum.rasa.com/u/Dustyposa)\
**Post date:** [July 13, 2021, 2:30am UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618/4 "2021-07-13T02:30:37Z")

</div>

I can think of three ways to do it：

1. In the `extract_xxx` function , you can add an addition. `if slot.get......`
2. Make it to `validate_xxx` function
3. Remove `experience_dose` from `required_slots`.

---

<div class="post-metadata">

**Author:** ![travelmail26](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/travelmail26/32/9388_2.png) [@travelmail26](https://forum.rasa.com/u/travelmail26)\
**Post date:** [July 13, 2021, 10:14pm UTC](https://forum.rasa.com/t/rasa-is-not-triggering-the-custom-form-action/45618/5 "2021-07-13T22:14:11Z")

</div>

So helpful! I tried the if slot.get solution but got two problems:

1. It’ triggers the if statement on subsequent slots. It should only happen for one thought

2. I encountered another issue: the Slotset function stopped working. Here is my normal code, which gets a list of items from a function (list\_tasks\_numbered\_names):

The line `return [SlotSet('asana_select_options_slot', tasklist)]` doesnt set the slot with tasklist. Something going with this loop?

Here’s how i implemented your solution below:

```
if tracker.get_slot('experience_dose'):
            text_of_last_user_message = tracker.latest_message.get("text")
        
            tasklist = list_tasks_numbered_names(text_of_last_user_message)

            resp = "Here is your task list: \n"+str(tasklist)
        
            print ('DEBUG: this is the task list', tasklist)
            dispatcher.utter_message(resp)
            return [SlotSet('asana_select_options_slot', tasklist)]
```
