# Slot filling feature is not working

**URL:** <https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864>\
**Category:** Rasa Open Source\
**Created:** [April 22, 2019, 12:23pm UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864 "2019-04-22T12:23:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anoopmohan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/anoopmohan/32/2722_2.png) [@anoopmohan](https://forum.rasa.com/u/anoopmohan)\
**Post date:** [April 22, 2019, 12:23pm UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/1 "2019-04-22T12:23:44Z")

</div>

Hi, I have a custom action file actions.py which contains a FormAction and added the necessary intents for that custom Form action. Now I have few questions here.

1. Should I update all the files (stories.md and domain.yml) manually?
2. If not, how can I generate the stories with slots using interactive learning feature for the FormAction, which is written in a custom action file?
3. Is it mandatory to add the validate method for the FormAction?

Even I tried the interactive learning after updating the domain.yml manually. But, the stories with slots (with prefix form:) is not generating automatically. Am I missing any part for slot filling feature?

package versions:

rasa-core==0.13.7 rasa-core-sdk==0.12.2 rasa-nlu==0.14.6

Here is my code in action file.

```
class CheckPerformanceIssueForm(FormAction):
    def name(self) -> Text:
        return "check_performance_issue"

    @staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
        return ["exp_resp_time", "cur_resp_time"]

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        return {
            "exp_resp_time": self.from_entity(entity="exp_resp_time", intent="inform"),
            "cur_resp_time": self.from_entity(entity="cur_resp_time", intent="inform"),
        }

    def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:
        dispatcher.utter_template("utter_submit", tracker)
        return []

```

Also, I am getting the following error when the user type the questions: 2019-04-22 11:46:27 ERROR **main** - Failed to validate slot cur\_resp\_time with action check\_performance\_issue

Please help.

Thank you in adv.

---

<div class="post-metadata">

**Author:** ![kamlesh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kamlesh/32/4072_2.png) [@kamlesh](https://forum.rasa.com/u/kamlesh)\
**Post date:** [April 23, 2019, 8:51am UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/2 "2019-04-23T08:51:27Z")

</div>

Ans 1- Yes, i think you should update your domain files manually. Adding forms sections in the domain file. Although for stories you can use [interactive learning](https://rasa.com/docs/core/interactive_learning/)

Ans 3- No, It is not mandatory.

---

<div class="post-metadata">

**Author:** ![anoopmohan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/anoopmohan/32/2722_2.png) [@anoopmohan](https://forum.rasa.com/u/anoopmohan)\
**Post date:** [April 23, 2019, 2:57pm UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/3 "2019-04-23T14:57:31Z")

</div>

Thanks @kamlesh for the reply.

In my case, I created a custom action file with FormAction in it and updated domain.yml for adding the form section. Then I tried the interactive learning, but could not see any interaction with “form:” prefix. It generates the story as just as the normal story and there are no story created with any “form:” prefix. Please tell me, if need to do anything specifically for this?

Thank you,

---

<div class="post-metadata">

**Author:** ![kamlesh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kamlesh/32/4072_2.png) [@kamlesh](https://forum.rasa.com/u/kamlesh)\
**Post date:** [April 24, 2019, 5:49am UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/4 "2019-04-24T05:49:09Z")

</div>

See apart from adding the form in the domain file and writing the Action for it make sure to check the below things.

1. You are using the forms to fill some slots - For that you need to write **four** functions in the form action given on this [link](https://rasa.com/docs/core/slotfilling/).

2 In the function slot mapping you can decide how to fill the slot - like from entity, intents or from free text.

3 Most important if you are adding it from a free text, i.e from user input text you need to add the following lines in the domain file in the templates sections. Rasa framework will utter these lines if the slot is not filled from the intents and entity.

utter\_ask\_your\_slot\_name:

```
- text: The question you want to ask to fill the slot?

```

I can see you have added the 4 functions and are you sure your slots are filled with the entity, you can add from text also, in that case rasa will utter the template to fill the slot . And make sure you have added the forms in the **story** too where you want to invoke it. For any doubt let me know.

---

<div class="post-metadata">

**Author:** ![anoopmohan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/anoopmohan/32/2722_2.png) [@anoopmohan](https://forum.rasa.com/u/anoopmohan)\
**Post date:** [April 24, 2019, 9:25am UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/5 "2019-04-24T09:25:07Z")

</div>

Thanks @kamlesh for the great explanation. That really helps.

I am confirming here that I get the slot values after modifying the slot mapping function and replace the entity with self.from\_text(). So, now my slot\_mappings() function returns

```
return {
            "exp_resp_time": [self.from_text()],
            "cur_resp_time": [self.from_text()],
        }

```

Also, I modified the domain slots values as:

```
slots:
  cur_resp_time:
    type: text
  exp_resp_time:
    type: text

```

This works fine for me. But, I would like to know few things along with this.

1. I would like to fill the slots from the entities that are defined in an intent called “inform”. Could you please tell me how can I achieve it?

Please find the sample values added to the intent “inform” in my nlu.md file

```
## intent:inform
- The expected response time is [two](exp_resp_time:2) seconds
- Expected is [three](exp_resp_time:3) sec
- I believe the expected response is [four](exp_resp_time:4) sec
- The expected could be [five](exp_resp_time:5)
- The curent could be [ten](cur_resp_time:10)
- I believe the expected response is [nine](cur_resp_time:9) sec
- Current response time is [eight](cur_resp_time:8) seconds
- The current response time is [seven](exp_resp_time:7) seconds

```

1. Please provide more details on the comment which you added " And make sure you have added the forms in the **story** too where you want to invoke it".

2. Do we need to add the forms manually to each stories?

3. Format for adding forms for each stories will be the same?

Please advise.

Thank you,

---

<div class="post-metadata">

**Author:** ![kamlesh](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/kamlesh/32/4072_2.png) [@kamlesh](https://forum.rasa.com/u/kamlesh)\
**Post date:** [April 24, 2019, 10:11am UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/6 "2019-04-24T10:11:56Z")

</div>

First thing read this [blog](https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction/)

I can see you have given **type text** to your slots, please go through the above article and see if it is right choice for you, as some time “text” type can hinder the story flow. Read more about it on [here](https://rasa.com/docs/core/slots/#) .

Ans 1 Yes you can fill the slots with entities - For that your training data need to be **labeled** for entities. For labeling the data you can use some UI tool to make the training data[also it can be manually done], its given on rasa git-hub page. And read about this [link](https://github.com/RasaHQ/rasa_core/blob/master/examples/formbot/data/nlu.md). You will see some text in **blue** this is tagging of data, telling what is what to rasa framework.

Ans 2 -I mean you have to invoke forms in your story if you are using them i.e they have to be part of the story, above link will give you some idea.

Ans 3 -Yes we need to add the form in stories. This is related to second point, so read the above blog. Ans 4- Yes the format is same.

---

<div class="post-metadata">

**Author:** ![anoopmohan](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/anoopmohan/32/2722_2.png) [@anoopmohan](https://forum.rasa.com/u/anoopmohan)\
**Post date:** [April 25, 2019, 3:02am UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/7 "2019-04-25T03:02:19Z")

</div>

Thank you very much @kamlesh . Will check the blog and come back to you, if I still have more questions.

Thank you,

---

<div class="post-metadata">

**Author:** ![MariamKA](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@MariamKA](https://forum.rasa.com/u/MariamKA)\
**Post date:** [October 26, 2020, 6:57pm UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/8 "2020-10-26T18:57:23Z")

</div>

Just wanna put it out there, sometimes you might end up not noticing that there’s a spacebar-space between [entity-value] bracket and (entity-name) bracket.

---

<div class="post-metadata">

**Author:** ![MariamKA](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@MariamKA](https://forum.rasa.com/u/MariamKA)\
**Post date:** [October 26, 2020, 6:58pm UTC](https://forum.rasa.com/t/slot-filling-feature-is-not-working/8864/9 "2020-10-26T18:58:30Z")

</div>

I had that error… wouldn’t have figured it out if not for your query-post.

Thank you @anoopmohan
