Hi everyone, I have just started learning Rasa. As my first exercise, I am trying to create this bot:
On the first message of user, bot respond with a welcome message and start getting the below data one by one and store in slots in tracker (don’t skip these portion if user give irrelevant data) and also validate the data. * Name * Age * State * How is your mood? (mood will be one of the 3 mentioned below moods, user can say cool or good but bot will consider it Happy): * Happy * Un-Happy * Aggressive * Based on user’s mood ask these below questions and store in slots: * On the scale of 0 to 10 how Happy/Un-Happy/Aggressive you are? * On the scale of 0 to 10 how much weather make you Happy/Un-Happy/Aggressive ?
I have created these files:
config.yml:
language: en
pipeline: supervised_embeddings
policies:
- name: MemoizationPolicy
- name: MappingPolicy
- name: FormPolicy
nlu.md:
## intent:greet
- hey
- hello
- hi
- hello there
- good morning
- good evening
- moin
- hey there
- let's go
- hey dude
- goodmorning
- goodevening
- good afternoon
## intent:name_entry
- My name is [Ali](name).
- My name is [Ahmed](name).
- My name is [Abdul Rehman](name).
- My name is [Allah Rakha](name).
- My name is [Samina Ahmed](name).
- My name is [Muhammad Umer](name).
- My name is [Muhammad Ijaz](name).
- My name is [M. Fahad](name).
- My name is [M. Ali](name).
- My name is [M. Tanveer](name).
- My name is [M. Yasir](name).
- My name is [M. Yaseen](name).
- My name is [Ayesha Khan](name).
- My name is [Farrukh](name).
- My name is [Fakhir](name).
- My name is [Fajar Khan](name).
- My name is [Noor Fatima](name).
- My name is [Areeba](name).
- My name is [Hammad](name).
- My name is [Afaq](name).
- My name is [Sara](name).
- My name is [Zainab](name).
- My name is [Amir](name).
- My name is [Nadia](name).
- My name is [Yusuf](name).
- My name is [Rabia](name).
- My name is [Imran](name).
- My name is [Maha](name).
- My name is [Tariq](name).
- My name is [Sadia](name).
- My name is [Kamran](name).
- My name is [Zoya](name).
- My name is [Bilal](name).
- My name is [Aisha](name).
- My name is [Omar](name).
- My name is [Hina](name).
- My name is [Rashid](name).
- My name is [Sana](name).
- My name is [Farhan](name).
- My name is [Samina](name).
- My name is [Ibrahim](name).
- My name is [Zain](name).
- My name is [Fiza](name).
- My name is [Nabeel](name).
- My name is [Sadaf](name).
- My name is [Usman](name).
- My name is [Amina](name).
- My name is [Junaid](name).
- My name is [Fariha](name).
- My name is [Tahir](name).
- My name is [Saima](name).
- My name is [Salman](name).
- My name is [Zara](name).
- My name is [Aliyah](name).
- My name is [Yasin](name).
- My name is [Nimra](name).
- My name is [Rizwan](name).
- My name is [Hira](name).
- My name is [Amin](name).
- My name is [Sobia](name).
- My name is [Khalid](name).
- My name is [Nida](name).
- My name is [Saad](name).
- My name is [Rukhsar](name).
- My name is [Waqar](name).
- My name is [Fahad](name).
- My name is [Sanaullah](name).
- My name is [Sidra](name).
- My name is [Adnan](name).
- My name is [Madiha](name).
- [Ali](name)
- [Ahmed](name)
- [Abdul Rehman](name)
- [Allah Rakha](name)
- [Samina Ahmed](name)
- [Muhammad Umer](name)
- [Muhammad Ijaz](name)
- [Muhammad Taha](name)
- [M. Fahad](name)
- [M. Ali](name)
- [M. Tanveer](name)
- [M. Yasir](name)
- [M. Yaseen](name)
- [Ayesha Khan](name)
- [Farrukh](name)
- [Fakhir](name)
- [Fajar Khan](name)
- [Ayesha](name)
- [Farrukh](name)
- [Fakhir](name)
- [Fajar](name)
- [Noor Fatima](name)
- [Areeba](name)
- [Hammad](name)
- [Afaq](name)
- [Sara](name)
- [Zainab](name)
- [Amir](name)
- [Nadia](name)
- [Yusuf](name)
- [Rabia](name)
- [Imran](name)
- [Maha](name)
- [Tariq](name)
- [Sadia](name)
- [Kamran](name)
- [Zoya](name)
- [Bilal](name)
- [Aisha](name)
- [Omar](name)
- [Hina](name)
- [Rashid](name)
- [Sana](name)
- [Farhan](name)
- [Samina](name)
- [Ibrahim](name)
- [Zain](name)
- [Fiza](name)
- [Nabeel](name)
- [Sadaf](name)
- [Usman](name)
- [Amina](name)
- [Junaid](name)
- [Fariha](name)
- [Tahir Shehzad](name)
- [Saima](name)
- [Salman](name)
- [Zara](name)
- [Aliyah](name)
- [Yasin](name)
- [Nimra](name)
- [Rizwan](name)
- [Hira](name)
- [Amin](name)
- [Sobia](name)
- [Khalid](name)
- [Nida](name)
- [Saad](name)
- [Rukhsar](name)
- [Waqar](name)
- [Fahad](name)
- [Sanaullah](name)
- [Sidra](name)
- [Adnan](name)
- [Madiha Farrukh](name)
- I go by the name [Ali](name).
- People call me [Ahmed](name).
- You can refer to me as [Abdul Rehman](name).
- Call me [Ayesha](name), please.
- Just call me [Farrukh](name).
- The name's [Fakhir](name).
- I respond to [Fajar](name).
- I'm [Noor Fatima](name).
- [Areeba](name) is what you can call me.
- They call me [Hammad](name).
- Friends call me [Afaq](name).
- You can address me as [Sara](name).
- Please refer to me as [Zainab](name).
- Just call me [Amir](name).
- I usually go by [Nadia](name).
- The name's [Yusuf](name).
- Call me [Rabia](name), if you would.
- Just call me [Imran](name).
- Please, call me [Maha](name).
- You can address me as [Tariq](name).
- I usually go by [Sadia](name).
- Just call me [Kamran](name).
- Call me [Zoya](name), if you would.
- Friends call me [Bilal](name).
- Please, refer to me as [Aisha](name).
- You can call me [Omar](name).
- Just call me [Hina](name).
- You can refer to me as [Rashid](name).
- I respond to [Sana](name).
- Please, call me [Farhan](name).
- Call me [Samina](name), if you would.
- Just call me [Ibrahim](name).
- You can refer to me as [Zain](name).
- Friends call me [Fiza](name).
- Please, call me [Nabeel](name).
- Just call me [Sadaf](name).
- You can call me [Usman](name).
- Please, refer to me as [Amina](name).
- Just call me [Junaid](name).
- Call me [Fariha](name), if you would.
- You can call me [Tahir](name).
- Just call me [Saima](name).
- Please, call me [Salman](name).
- You can refer to me as [Zara](name).
- Call me [Aliyah](name), if you would.
- Just call me [Yasin](name).
- You can call me [Nimra](name).
- Please, refer to me as [Rizwan](name).
- Just call me [Hira](name).
- Call me [Amin](name), if you would.
- You can call me [Sobia](name).
- Please, refer to me as [Khalid](name).
- Just call me [Nida](name).
- You can call me [Saad](name).
- Just call me [Rukhsar](name).
- You can refer to me as [Waqar](name).
- Call me [Fahad](name), if you would.
- Just call me [Sanaullah](name).
- Please, refer to me as [Sidra](name).
- You can call me [Adnan](name).
- Just call me [Madiha](name).
## intent:number_entry
- [0](number)
- [1](number)
- [2](number)
- [3](number)
- [4](number)
- [5](number)
- [6](number)
- [7](number)
- [8](number)
- [9](number)
- [19](number)
- [8](number)
- [09](number)
- [20](number)
- [50](number)
- [80](number)
- [27](number)
- I am [25](number) years old.
- My number is [30](number).
- [18](number) years young.
- I'm [40](number) years old.
- [22](number) years of number.
- I recently turned [27](number).
- I just hit [50](number) years.
- I'm in my [early 30s](number).
- I'm [19](number) years old.
- [60](number) years and counting.
- I'm [28](number) years young.
- Currently [21](number) years old.
- I'm in my [late 40s](number).
- I'm [35](number) years old.
- I'm a [teennumberr](number).
- I'm [23](number) years old.
- [29](number) and thriving.
- I'm [42](number) years of number.
- I just turned [20](number).
- I'm [55](number) years young.
- I'm [33](number) years old.
- [45](number) and fabulous.
- I'm [31](number) years old.
- I'm [16](number) years old.
- [38](number) years and going strong.
- I'm [26](number) years young.
- I'm [17](number) years old.
- [48](number) years and loving it.
- I'm [24](number) years old.
- I'm [56](number) years old.
- [36](number) years and counting.
- I'm [39](number) years old.
- I'm [44](number) years young.
- [51](number) and still fabulous.
- I'm [14](number) years old.
- I'm [34](number) years old.
- [58](number) years young.
- I'm [22](number) years young.
- [41](number) and feeling great.
- I'm [32](number) years old.
- I'm [47](number) years old.
- [65](number) and loving life.
- I'm [13](number) years old.
- I'm [27](number) years old.
- [53](number) and thriving.
- I'm [37](number) years old.
- I'm [15](number) years old.
- [46](number) years and fabulous.
- I'm [59](number) years old.
- I'm [21](number) years young.
- [43](number) years and counting.
- I'm [12](number) years old.
- I'm [25](number) years young.
- [49](number) years of wisdom.
- I'm [70](number) years young.
- [28](number) and fabulous.
- I'm [63](number) years old.
- [20](number) something.
- I'm [85](number) years old.
- I'm [18](number) years young.
- [75](number) and loving life.
- I'm [19](number) years young.
- I'm [88](number) years old.
- [42](number) years of experience.
- I'm [23](number) years young.
- I'm [55](number) years old.
- [37](number) and feeling great.
- I'm [29](number) years young.
- I'm [67](number) years old.
- [21](number) and thriving.
- I'm [51](number) years young.
- I'm [26](number) years old.
- [59](number) and fabulous.
- I'm [31](number) years young.
## synonym:Khyber Pakhtunkhwa
- kpk
- kp
- KPK
- KP
- Khyper Pakhtunkhwa
- khyper pakhtunkhwa
## synonym:Giglit-Baltistan
- gb
- gilgit baltistan
- gilgit
- Gilgit
- GB
- Gilgit Baltistan
## synonym:Azad Jammu and Kashmir
- ajk
- azad kashmir
- kashmir
- jammu kashmir
- azad jammu kashmir
- AJK
- Azad Kashmir
- Kashmir
- Jammu Kashmir
- Azad Jammu Kashmir
## synonym:Islamabad Capital Territory
- ict
- islamabad
- ICT
- Islamabad
- islamabad
## synonym:Punjab
- punjab
## synonym:Sindh
- sindh
## synonym:Balochistan
- balochistan
## intent:state_entry
- [ajk](state)
- [azad kashmir](state)
- [kashmir](state)
- [jammu kashmir](state)
- [azad jammu kashmir](state)
- [AJK](state)
- [Azad Kashmir](state)
- [Kashmir](state)
- [Jammu Kashmir](state)
- [Azad Jammu Kashmir](state)
- [Azad Jammu and Kashmir](state)
- [punjab](state)
- [Punjab](state)
- [sindh](state)
- [Sindh](state)
- [kpk](state)
- [KPK](state)
- [Khyper Pakhtunkhwa](state)
- [khyper pakhtunkhwa](state)
- [ict](state)
- [ICT](state)
- [Islamabad](state)
- [islamabad](state)
- [Balochistan](state)
- [balochistan](state)
- [gilgit](state)
- [Gilgit](state)
- [GB](state)
- [gb](state)
- [gilgit baltistan](state)
- [Gilgit Baltistan](state)
- I live in [Punjab](state).
- My state is [Sindh](state).
- [Kashmir](state) is where I'm from.
- I'm from [Gilgit-Baltistan](state).
- I reside in [Balochistan](state).
- [KPK](state) is my home state.
- I live in [Islamabad](state).
- My state is [Punjab](state).
- [Gilgit-Baltistan](state) is where I'm located.
- I'm from [KPK](state).
- I reside in [Sindh](state).
- [Kashmir](state) is my home state.
- I live in [Balochistan](state).
- My state is [Islamabad](state).
- [KPK](state) is where I'm located.
- I'm from [Gilgit-Baltistan](state).
- I reside in [Punjab](state).
- [Sindh](state) is my home state.
- I live in [Kashmir](state).
- My state is [Balochistan](state).
- [Islamabad](state) is where I'm located.
- I'm from [KPK](state).
- I reside in [Gilgit-Baltistan](state).
- [Sindh](state) is my home state.
- I live in [Balochistan](state).
- My state is [Kashmir](state).
- [Islamabad](state) is where I'm located.
- I'm from [KPK](state).
- I reside in [Gilgit-Baltistan](state).
- [Punjab](state) is my home state.
- I live in [Sindh](state).
- My state is [Kashmir](state).
- [Balochistan](state) is where I'm located.
- I'm from [Gilgit-Baltistan](state).
- I reside in [KPK](state).
- [Islamabad](state) is my home state.
## intent:mood_entry
- [Happy](mood)
- [Cool](mood)
- [Good](mood)
- [Excellent](mood)
- [Great](mood)
- [happy](mood)
- [cool](mood)
- [good](mood)
- [excellent](mood)
- [great](mood)
- [Un-Happy](mood)
- [Un Happy](mood)
- [Unhappy](mood)
- [Not Happy](mood)
- [Not Good](mood)
- [Sad](mood)
- [Bad](mood)
- [Depress](mood)
- [Depressed](mood)
- [un-happy](mood)
- [un happy](mood)
- [unhappy](mood)
- [not happy](mood)
- [sad](mood)
- [bad](mood)
- [depress](mood)
- [depressed](mood)
- [Aggressive](mood)
- [Angry](mood)
- [Frustrated](mood)
- [aggressive](mood)
- [angry](mood)
- [frustrated](mood)
- I'm feeling [happy](mood).
- Today has been [excellent](mood).
- My mood is [good](mood) today.
- I'm [feeling great](mood) right now.
- [Cool](mood), everything is going well.
- I'm quite [content](mood) at the moment.
- It's been a [happy](mood) day so far.
- I'm in an [upbeat](mood) mood.
- I'm [joyful](mood) today.
- [Pleased](mood) with how things are going.
- Unfortunately, I'm [unhappy](mood) today.
- My mood is [sad](mood) right now.
- I've been feeling a bit [depressed](mood) lately.
- Things are [bad](mood) at the moment.
- I'm [feeling down](mood) today.
- Unfortunately, I'm [not in a good mood](mood) right now.
- It's been a [tough day](mood) for me.
- I'm feeling quite [angry](mood).
- My mood is a bit [aggressive](mood) right now.
- I'm [frustrated](mood) with the situation.
- Today's been [wonderful](mood) so far.
- I'm [ecstatic](mood) about the news.
- My mood is [uplifting](mood) right now.
- Feeling [fantastic](mood) today.
- [Elated](mood) by recent events.
- I'm [positive](mood) and optimistic.
- I'm [sad](mood) about the outcome.
- [Disheartened](mood) by the situation.
- My mood is [gloomy](mood) today.
- [Dismal](mood) weather got me down.
- Feeling [irritable](mood) due to circumstances.
- I'm [livid](mood) right now.
- [Enraged](mood) by the injustice.
- My mood is [furious](mood) today.
- [Annoyed](mood) by the constant noise.
- I'm [enraged](mood) and frustrated.
- [Irate](mood) due to the delay.
- My mood is [calm](mood) and peaceful.
- Feeling [relaxed](mood) after a long day.
- [Tranquil](mood) and at ease.
- I'm [distressed](mood) by recent events.
- [Melancholic](mood) over the loss.
- My mood is [restless](mood) today.
- Feeling [weary](mood) after a busy day.
- [Hurt](mood) by their actions.
- I'm [fuming](mood) about the situation.
- [Agitated](mood) due to the confusion.
- My mood is [composed](mood) and steady.
- Feeling [serene](mood) in this peaceful setting.
- [Blissful](mood) after spending time with loved ones.
- I'm [annoyed](mood) by the repeated disruptions.
## synonym:happy
- exellent
- good
- feeling great
- blissful
- serene
- composed
- tranquil
- relaxed
- calm
- positive
- elated
- fantastic
- uplifting
- ecstatic
- wonderful
- pleased
- joyful
- upbeat
- content
- cool
- Happy
- Cool
- Good
- Excellent
- Great
- excellent
- great
## synonym:unhappy
- unhappy
- sad
- depressed
- miserable
- bad
- feeling down
- not in a good mood
- tough day
- disheartened
- gloomy
- dismal
- irritable
- distressed
- melancholic
- restless
- weary
- hurt
- Un-Happy
- Un Happy
- Unhappy
- Not Happy
- Sad
- Bad
- Depress
- Depressed
- un-happy
- un happy
- not happy
- depress
- depressed
## synonym:agressive
- annoyed
- agitated
- fuming
- irate
- angry
- enraged
- livid
- frustrated
- Aggressive
- Angry
- Frustrated
- aggressive
## intent:chitchat
- no
- i don't want to tell
- exit
- leave it here
## regex:number
- ^[0-9]{1,2}$
## regex:name
- ^[A-Za-z]+(?:[\s\-][A-Za-z]+)*$
stories.md:
## userinfo happy path
* greet
- utter_greet
- userinfo_form
- form{"name": "userinfo_form"}
- form{"name": null}
- moodrating_form
- form{"name": "moodrating_form"}
- form{"name": null}
- weatherrating_form
- form{"name": "weatherrating_form"}
- form{"name": null}
- utter_slots_values
## userinfo chitchat path
* greet
- utter_greet
- userinfo_form
- form{"name": "userinfo_form"}
* chitchat
- utter_chitchat
- form{"name": "userinfo_form"}
- form{"name": null}
- moodrating_form
- form{"name": "moodrating_form"}
- form{"name": null}
- weatherrating_form
- form{"name": "weatherrating_form"}
- form{"name": null}
- utter_slots_values
domain.yml:
intents:
- greet
- goodbye
- name_entry
- number_entry
- state_entry
- mood_entry
- chitchat
forms:
- userinfo_form
- moodrating_form
- weatherrating_form
entities:
- name
- age
- state
- mood
- moodrating
- weatherrating
actions:
- action_check_slots
slots:
name:
type: unfeaturized
age:
type: unfeaturized
state:
type: unfeaturized
mood:
type: unfeaturized
moodrating:
type: unfeaturized
weatherrating:
type: unfeaturized
responses:
utter_greet:
- text: "Welcome! I want some information before we proceed"
utter_ask_name:
- text: "What is your name?"
utter_ask_age:
- text: "How old are you?"
utter_ask_state:
- text: "In which state do you live?"
utter_ask_mood:
- text: "How is your mood today?"
utter_ask_moodrating:
- text: "On a scale of 0-9, how {mood} are you?"
utter_ask_weatherrating:
- text: "On a scale of 0-9, how much weather makes you {mood}?"
utter_submit:
- text: "Thank you for providing information!"
utter_slots_values:
- text: "I have saved this information:\n
- name: {name}\n
- age: {age}\n
- state: {state}\n
- mood: {mood}\n
- mood rating: {moodrating}\n
- weather rating: {weatherrating}"
utter_chitchat:
- text: "Sorry! Please enter {requested_slot} again"
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
actions.py:
from typing import Any, Text, Dict, List, Union
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction
from rasa_sdk.events import SlotSet
class ActionUserInfoForm(FormAction):
def name(self) -> Text:
return "userinfo_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
print("required_slots(tracker: Tracker)")
return ["name", "age", "state", "mood"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return{
"age": [
self.from_entity(entity='number', intent=["number_entry"]),
]
}
def submit(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
return []
class ActionMoodRatingForm(FormAction):
def name(self) -> Text:
return "moodrating_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["moodrating"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"moodrating": [
self.from_entity(entity='number', intent=["number_entry"]),
]
}
def validate_moodrating(
self,
value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if int(value) < 0:
return {"moodrating": 0}
elif int(value) > 9:
return {"moodrating": 9}
else:
return {"moodrating": str(value)}
def submit(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
moodrating = tracker.get_slot("moodrating")
return [SlotSet("moodrating", moodrating)]
class ActionWeatherRatingForm(FormAction):
def name(self) -> Text:
return "weatherrating_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
return ["weatherrating"]
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"weatherrating": [
self.from_entity(entity='number', intent=["number_entry"]),
]
}
def validate_weatherrating(
self,
value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if int(value) < 0:
return {"weatherrating": 0}
elif int(value) > 9:
return {"weatherrating": 9}
else:
return {"weatherrating": str(value)}
def submit(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict]:
weatherrating = tracker.get_slot("weatherrating")
dispatcher.utter_message(template="utter_submit")
return [SlotSet("weatherrating", weatherrating)]
The problems I am facing include:
- When user enters any message during form entry, the action_execution_rejected occurs and no message is displayed. Secondly, since the story breaks in this case, the next form is not executed.
- To handle the above issue, I created this chitchat intent, but it also does not handles the problem.
I want these three forms to executed simultaneously without any interruption with these conditions:
- Don’t catch any intent while forms are executing.
- If user doesn’t fill any slot, ask to him/her again.
- After ending one form, other should be called until all slots are filled.
Please help me with this as I am a beginner and don’t know much about Rasa!