I am following youtube videos on Rasa open source. I wanted to set my slot using custom action and then retrieve it again by a custom action. Slot is setting correctly but the next action which is to retrieve slot value is overridden by action_default_fallback.
NLU.yml
- intent: tell_name
examples: | - I want to tell you my name. - give name - do you know my name? - i’ll give you my name.
-
intent: repeat_name examples: |
- what is my name
- tell me my name
- do you know my name
- repeat my name
-
intent: give_name examples: |
- Rajat
- Vincent
- Anand
- Rahul
- Ashish
STORY.yml
- story: name path
steps:
- intent: greet
- action: utter_greet
- intent: tell_name
- action: utter_ask_name
- intent: give_name
- action: action_receive_name
- intent: repeat_name
- action: action_say_name
DOMAIN.yml version: “2.0”
intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- tell_name
- give_name
- repeat_name
entities:
slots: name: type: text
actions:
- action_receive_name
- action_say_name
responses: utter_greet:
- text: “Hey! How are you?”
utter_cheer_up:
- text: “Here is something to cheer you up:” image: “https://i.imgur.com/nGF1K8f.jpg”
utter_did_that_help:
- text: “Did that help you?”
utter_happy:
- text: “Great, carry on!”
utter_goodbye:
- text: “Bye”
utter_iamabot:
- text: “I am a bot, powered by Rasa.”
utter_ask_name:
- text: “What is your name?”
session_config: session_expiration_time: 60 carry_over_slots_to_new_session: true
actions.py
from typing import Any, Text, Dict, List
from rasa_sdk.events import SlotSet from rasa_sdk import Action, Tracker from rasa_sdk.executor import CollectingDispatcher
class ActionReceiveName(Action):
def name(self) -> Text:
return "action_receive_name"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
text = tracker.latest_message['text']
print("this action class is working")
dispatcher.utter_message(text=f"I will remember your name : {text}")
return [SlotSet("name", text)]
class ActionSayName(Action):
def name(self) -> Text:
return "action_say_name"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
name = tracker.get_slot("name")
print("rajat"+" "+name)
if not name:
dispatcher.utter_message(text="I don't know your name :(")
else:
dispatcher.utter_message(text=f"Your name is {name}!")
return []
Instead of getting name from second custom action, I am getting “You input” prompt.