traube
(Valentin Laucht)
November 23, 2020, 8:53am
1
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
stephens
(Greg Stephens)
November 23, 2020, 7:57pm
2
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:
slots:
example:
type: text
You should also consider using action_session_start for this purpose.
traube
(Valentin Laucht)
November 23, 2020, 9:04pm
3
@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!
stephens
(Greg Stephens)
November 23, 2020, 10:12pm
4
traube:
text: "Show { example }"
remove the spaces around example: {example}
traube
(Valentin Laucht)
November 26, 2020, 8:41am
6
@stephens Can I ask one more question?
Do you have any idea why my action_session_start is not getting triggered?
I’m trying to override action_session_start to fill some slots on session start.
I’ve just copied this example: ActionSessionStart 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