# Rasa 2.0 Forms does not validate extracted slots and asks the next slot

**URL:** https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879
**Category:** Rasa Open Source
**Created:** [October 14, 2020, 12:21pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879 "2020-10-14T12:21:51Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 12:21pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/1 "2020-10-14T12:21:51Z")

</div>

@akelad need your help here. Thanks

Slots gets extracted but does not get validated using `validate_<slot_name>` function. Following current guidelines here [Forms](https://rasa.com/docs/rasa/forms#validating-form-input) Logs

```auto
2020-10-14 17:06:20 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 297 events.
2020-10-14 17:06:20 DEBUG rasa.core.policies.rule_policy - Predicted loop ‘order_form’. 
2020-10-14 17:06:20 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_RulePolicy 
2020-10-14 17:06:20 DEBUG rasa.core.processor - Predicted next action ‘order_form’ with confidence 1.00. 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Validating user input ‘UserUttered(text: lays, intent: {‘id’: 3152659454284902011, ‘name’: ‘inform’, ‘confidence’: 0.999991774559021}, entities: [{‘entity’: ‘snack’, ‘start’: 0, ‘end’: 4, ‘confidence_entity’: 0.8661425709724426, ‘value’: ‘lays’, ‘extractor’: ‘DIETClassifier’}])’. 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Trying to extract requested slot ‘snack’ … 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Got mapping ‘{‘type’: ‘from_entity’, ‘entity’: ‘snack’}’ 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Successfully extracted ‘lays’ for requested slot ‘snack’ 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Validating extracted slots: {‘snack’: ‘lays’} 
2020-10-14 17:06:20 DEBUG rasa.core.actions.action - Calling action endpoint to run action ‘validate_order_form’. 
2020-10-14 17:06:20 DEBUG rasa.core.actions.forms - Request next slot ‘size’

```

and My custom action:

```auto
from typing import Dict, Text, List

from rasa_sdk import Tracker
from rasa_sdk.events import EventType
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk import Action
from rasa_sdk.events import SlotSet
from typing import Text, List, Any, Dict
from rasa_sdk import Tracker, FormValidationAction
from rasa_sdk.types import DomainDict
from rasa.shared.core.domain import Domain

class ActionSwitchFAQ(Action):
    def name(self) -> Text:
        return "action_switch_faq"

    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        return [SlotSet("detailed_faq", not tracker.get_slot("detailed_faq"))]

class ValidateOrderForm(FormValidationAction, Action):
    def name(self) -> Text:
        """Unique identifier of the form"""

        return "validate_order_form"
    
    def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
    ) -> List[EventType]:
        # dispatcher.utter_message("validate_some_slot")
        # return [SlotSet("some_slot", "sdk")]
        return []

    def validate_snack(
        self,
        slot_value: Any,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: DomainDict,
    ) -> Dict[Text, Any]:
        """Validate cuisine value."""
        
        print("Slot Value=", slot_value)
        if slot_value == "fries":
            print("validation succeeded")
            return {"snack": slot_value}
        else:
            print("validation failed")
            # user will be asked for the slot again
            return {"snack": None}
    
    def validate_size(
        self,
        slot_value: Any,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: DomainDict,
    ) -> Dict[Text, Any]:
        """Validate cuisine value."""
        
        print("Slot Value=", slot_value)
        if slot_value == "large":
            print("validation succeeded")
            return {"size": slot_value}
        else:
            print("validation failed")
            # user will be asked for the slot again
            return {"size": None} `

```

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 12:28pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/2 "2020-10-14T12:28:52Z")

</div>

Could you share the logs of your action server? It seems like it does call your action server to validate the slots

---

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 12:35pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/3 "2020-10-14T12:35:33Z")

</div>

Logs before filling the `snack` slot

```
2020-10-14 17:32:58 **INFO** rasa_sdk.endpoint - Starting action endpoint server...
2020-10-14 17:32:58 **INFO** rasa_sdk.executor - Registered function for 'action_switch_faq'.
2020-10-14 17:32:58 **INFO** rasa_sdk.executor - Registered function for 'validate_order_form'.
2020-10-14 17:32:58 **INFO** rasa_sdk.endpoint - Action endpoint is up and running on http://localhost:5055
validate_order_form Run Called
```

Logs after i enter the value for `snack` slot

```
2020-10-14 17:32:58 **INFO** rasa_sdk.endpoint - Starting action endpoint server...
2020-10-14 17:32:58 **INFO** rasa_sdk.executor - Registered function for 'action_switch_faq'.
2020-10-14 17:32:58 **INFO** rasa_sdk.executor - Registered function for 'validate_order_form'.
2020-10-14 17:32:58 **INFO** rasa_sdk.endpoint - Action endpoint is up and running on http://localhost:5055
validate_order_form Run Called
validate_order_form Run Called
```

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 12:39pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/4 "2020-10-14T12:39:52Z")

</div>

ahhh @noman it’s because you overwrote the `run()` function, which now doesn’t do anything. If you remove it I believe it should work

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 12:41pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/5 "2020-10-14T12:41:36Z")

</div>

And you should only need to subclass the `FormValidationAction` so that it’s `class ValidateOrderForm(FormValidationAction)`

The default implementation of the run method is listed [here](https://github.com/RasaHQ/rasa-sdk/blob/master/rasa_sdk/forms.py#L746)

---

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 12:41pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/6 "2020-10-14T12:41:50Z")

</div>

ahan ok but to add custom slot mappings and require extra slots we need to override run function as stated here [Forms](https://rasa.com/docs/rasa/forms#custom-slot-mappings). Then in this case what will we do?

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 12:55pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/7 "2020-10-14T12:55:03Z")

</div>

Then you subclass a normal `Action`, and define the validation logic there. You can find an example in Sara, our demo bot, [here](https://github.com/RasaHQ/rasa-demo/blob/rasa-2.0/actions/actions.py#L50) - keeping in mind that the method has been renamed to `tracker.slots_to_validate`. The example is still in process of being updated

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 1:00pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/8 "2020-10-14T13:00:29Z")

</div>

In helping you out with this I realise that that implementation isn’t ideal, and the docs are also a little bit confusing! Will talk to our team on how to address this 🙂

---

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 1:00pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/9 "2020-10-14T13:00:37Z")

</div>

ok Thanks. @akelad can i keep using `FormAction` from `rasa_sdk` with rasa==2.0?

---

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 1:01pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/10 "2020-10-14T13:01:09Z")

</div>

Yeah it would be great 🙂

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 1:16pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/11 "2020-10-14T13:16:01Z")

</div>

hm, i think it’s still gonna work for now, but we will deprecate it eventually. So it’s better to migrate eventually. Are there any particular parts you’re struggling with?

---

<div class="post-metadata">

### Author: ![noman](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/noman/32/10071_2.png) [@noman](https://forum.rasa.com/u/noman)
#### Post date: [October 14, 2020, 1:18pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/12 "2020-10-14T13:18:31Z")

</div>

Hmm ok. Right now i was facing the problem in validation, if i face any while exploring rasa==2.0, will ping you. Thanks for the help.

---

<div class="post-metadata">

### Author: ![petasis](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@petasis](https://forum.rasa.com/u/petasis)
#### Post date: [October 14, 2020, 3:06pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/13 "2020-10-14T15:06:30Z")

</div>

Of course, even after migration, there is a bug in Rasa 2.0 and extracted slots will get again ignored, and the form will ask again for the slots.

Currently there is no way to get this working, we are awaiting for a fix.

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 14, 2020, 3:14pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/14 "2020-10-14T15:14:57Z")

</div>

@petasis not sure what you mean, as far as I understood your particular issue is with slots from the trigger message. As already mentioned, we’re working on looking into this and will update you when there’s an update. Repeatedly posting about this isn’t going to speed things up.

If you are talking about a different issue than I assumed, then please feel free to open another post so that we can address that separately.

---

<div class="post-metadata">

### Author: ![petasis](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@petasis](https://forum.rasa.com/u/petasis)
#### Post date: [October 14, 2020, 4:10pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/15 "2020-10-14T16:10:03Z")

</div>

No, I am talking about a different issue, the slots of trigger messages is the bug that makes my bot unusable. I started migration to rasa 2.x on September 28, having a deadline for a demo on October 5. Then I realised that it was not my fault my forms were not working, I updated from rc3 to rc4, found a workround for rc4 on October 7, and on October 8 you released version 2.0. Which changed again how forms should work (from rc4), I updated again my bot, but my forms still do not work, and I cannot find a work around. 7 days later, I still have no solution, no demo, and no plan for a fix from rasa.

What should I do? Go back to 2.0.rc4? Go back to 1.x?

(And if you remember this thread [Rasa 2.0, how are forms working?](http://forum.rasa.com/t/rasa-2-0-how-are-forms-working/35425/5), the problem exists for almost 30 days, and I was hopping 2.0 would fix it - which didn’t -, and the bug has been closed). I really do not know how to proceed.

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 15, 2020, 9:01am UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/16 "2020-10-15T09:01:37Z")

</div>

I’m not sure what you mean, that sounds like the issue I was talking about? The PR submitted that you linked to did fix the issue for our bots. As I asked in the other [thread](http://forum.rasa.com/t/rasa-open-source-2-0-is-out-now/35577/47), it would be great if you can open a _new_ post with all the details related to your issue, since that thread has gotten confusing, with other peoples issues, and also the data being in various different forum posts.

---

<div class="post-metadata">

### Author: ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)
#### Post date: [October 15, 2020, 3:17pm UTC](https://forum.rasa.com/t/rasa-2-0-forms-does-not-validate-extracted-slots-and-asks-the-next-slot/35879/17 "2020-10-15T15:17:03Z")

</div>

btw if you can’t share your code publicly, feel free to email [support@rasa.com](mailto:support@rasa.com) and we can help you that way
