# Rasa 2.1 fill slots from custom action

**URL:** <https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278>\
**Category:** Rasa Open Source\
**Created:** [November 23, 2020, 8:53am UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278 "2020-11-23T08:53:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![traube](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/traube/32/11965_2.png) [@traube](https://forum.rasa.com/u/traube)\
**Post date:** [November 23, 2020, 8:53am UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/1 "2020-11-23T08:53:14Z")

</div>

I’m trying to build a bot with rasa. At the very beginning of the conversation it should fill some slots with data from the database.

I have a custom action:

```
class ActionFillSlots(Action):

def name(self) -> Text:
    return "action_fill_slots"

def run(self, dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

    example = "example"
    return [SlotSet("example", example)]

```

And in my domain.yml file i have set the slot like this:

```
slots:
  example:
  type: text

```

And a response like:

```
 utter_greet:
 - text: "Show { example }"

```

And in my stories.yml file, i have stories like:

```
- story: greet happy path
  steps:
  - intent: greet
  - action: action_fill_slots
  - action: utter_greet

```

If I run the bot with `rasa shell --debug` and then type something that matches the greeting intent, i get the following error:

> Failed to fill utterance template ‘Show { example }’ Tried to replace ’ example ’ but could not find a valu e for it. There is no slot with this name nor did you pass the value explicitly when calling the template. Return template without filling the template.

In my debug window I can see, that the slot has been set by the action:

> Current slot values: example: example

I’m using rasa 2.1.0

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [November 23, 2020, 7:57pm UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/2 "2020-11-23T19:57:58Z")

</div>

The `type` is not indented correctly in your `domain.yml`. But, if this is not a featurized slot, you can remove type. It should be like this:

```auto
slots:
  example:
    type: text

```

You should also consider using [action\_session\_start](https://rasa.com/docs/rasa/default-actions#action_session_start) for this purpose.

---

<div class="post-metadata">

**Author:** ![traube](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/traube/32/11965_2.png) [@traube](https://forum.rasa.com/u/traube)\
**Post date:** [November 23, 2020, 9:04pm UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/3 "2020-11-23T21:04:46Z")

</div>

@stephensThanks for your reply. This was a mistake I made while pasting it here. In my code it is indented correctly. Do you have another idea? Thanks for the hint with action\_session\_start!

---

<div class="post-metadata">

**Author:** ![stephens](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/stephens/32/1632_2.png) [@stephens](https://forum.rasa.com/u/stephens)\
**Post date:** [November 23, 2020, 10:12pm UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/4 "2020-11-23T22:12:38Z")

</div>

> [@traube](#):
>
> `text: "Show { example }"`

remove the spaces around example: `{example}`

---

<div class="post-metadata">

**Author:** ![traube](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/traube/32/11965_2.png) [@traube](https://forum.rasa.com/u/traube)\
**Post date:** [November 24, 2020, 2:18pm UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/5 "2020-11-24T14:18:54Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![traube](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/traube/32/11965_2.png) [@traube](https://forum.rasa.com/u/traube)\
**Post date:** [November 26, 2020, 8:41am UTC](https://forum.rasa.com/t/rasa-2-1-fill-slots-from-custom-action/37278/6 "2020-11-26T08:41:59Z")

</div>

@stephens Can I ask one more question? Do you have any idea why my action\_session\_start is not getting triggered?

> [@Action\_session\_start not getting triggered](http://forum.rasa.com/t/action-session-start-not-getting-triggered/37353):
>
> I’m trying to override action\_session\_start to fill some slots on session start. I’ve just copied this example: [ActionSessionStart](https://rasa.com/docs/rasa/default-actions) to my actions.py and just changed the fetch\_slots method. If I run rasa run actions --debug I can see, that this action is registered: 2020-11-24 17:19:19 INFO rasa\_sdk.executor - Registered function for ‘action\_session\_start’. But neither on my first message, nor on manually triggering /start\_session the action is getting triggered. It does work with other a…

Thanks
