# Custom Action is not predicted when FormAction is active

**URL:** <https://forum.rasa.com/t/custom-action-is-not-predicted-when-formaction-is-active/4213>\
**Category:** Rasa Open Source\
**Created:** [January 10, 2019, 11:20am UTC](https://forum.rasa.com/t/custom-action-is-not-predicted-when-formaction-is-active/4213 "2019-01-10T11:20:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauraperge](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lauraperge/32/1073_2.png) [@lauraperge](https://forum.rasa.com/u/lauraperge)\
**Post date:** [January 10, 2019, 11:20am UTC](https://forum.rasa.com/t/custom-action-is-not-predicted-when-formaction-is-active/4213/1 "2019-01-10T11:20:14Z")

</div>

I have multiple FormActions which belong to different story types. Both FormActions need similar inputs with a couple exceptions.

The first requested field (with conditional slot logic) is the email address of the user, which needs to be

1. validated by checking if in DB
2. if valid, it is used to retrieve some other information from the DB and set slots accordingly. This is needed to get confirmation from the user **before** executing the FormAction

Now, I tried adding a function to the class that I could use in the validate() function within the FormAction class, similarly as [here](https://github.com/RasaHQ/rasa_core/blob/70c6bfebcd2ec41f0daf9a62f5029e0c0a4a32c4/examples/formbot/actions.py#L54). But returning the SlotSet event did not change the slots I need to modify (guess because it is within the class). Therefore, I created a custom validation action, that is added to the stories when the email slot is set:

```auto
* provideemail{"email": "example@example.no"}
    - slot{"email": "example@example.no"}
    - action_validateEmail

```

This action also returns the followup action to be the active FormAction if any is active, or chooses the followup action according to story. This seems to be great because multiple forms need this validation, and if I force the path in online training, the conversation is exactly what I need, it just doesn’t get predicted. It also works without error in online training when the the FormAction is not yet active (e.g. email address is given before request that initiates FormAction.

**The problem is that when the FormAction is already activated, once the email address is entered by the user, the validation action never gets predicted. It is always the FormAction that keeps being predicted.**

Is there any way to get around this? My ideas and problems:

1. Adding the validation inside the FormAction - _cannot set other slots that are required to carry out the form. These are not retrieved from the user, but need to be returned to them before finishing form action_

2. The above solution with the external validation - _not getting predicted_

Please let me know if you have any ideas what could be a get around!

---

<div class="post-metadata">

**Author:** ![hrxx](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@hrxx](https://forum.rasa.com/u/hrxx)\
**Post date:** [January 18, 2019, 10:44am UTC](https://forum.rasa.com/t/custom-action-is-not-predicted-when-formaction-is-active/4213/2 "2019-01-18T10:44:15Z")

</div>

If you did not change the default config, rasa core will first use memory prediction policy, if it failed, then the Keras policy. It is hard to find out the reason Keras make an incorrect prediction. Maybe you can add more training data.

---

<div class="post-metadata">

**Author:** ![lauraperge](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lauraperge/32/1073_2.png) [@lauraperge](https://forum.rasa.com/u/lauraperge)\
**Post date:** [January 18, 2019, 12:57pm UTC](https://forum.rasa.com/t/custom-action-is-not-predicted-when-formaction-is-active/4213/3 "2019-01-18T12:57:42Z")

</div>

Thanks for the answer.

I ended up modifying everything a bit, and adding a FormAction deactivation whenever the validation Action hasn’t been executed yet (or not successfully).

Then the bot carries on and reactivates the relevant form according to stories.
