Rasa 2.1 fill slots from custom action

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:

  type: text

And a response like:

 - text: "Show { example }"

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

- story: greet happy path
  - 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

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:

    type: text

You should also consider using action_session_start for this purpose.

@stephens Thanks 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!

remove the spaces around example: {example}

Thank you!

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