- this is my action.py:*
from typing import Dict, Text, Any, List, Union, Optional
from rasa_sdk import Tracker from rasa_sdk.executor import CollectingDispatcher from rasa_sdk.forms import FormAction
class IssueForm(FormAction):
def name(self) -> Text:
"""Unique identifier of the form"""
return "issue_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
return ['item','brand','part']
def validate_item(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
"""Validate item"""
if isinstance(value, str):
if "mobile" in value:
return {"item": value}
elif "laptop" in value:
return {"item": value}
else:
dispatcher.utter_message(template="utter_wrong_item")
return {"item": None}
else:
return {"item": value}
@staticmethod
def brands_db() -> List[Text]:
"""Database of supported brands"""
return [
"lenovo",
"asus",
"apple",
"sony",
"vio",
"dell",
"toshiba",
"hp",
"msi",
"asus",
"apple",
"sony",
"xiomi",
"realme",
"oneplus",
"lg",
"oppo",
"vivo",
"acer",
]
@staticmethod
def parts_db() -> List[Text]:
"""Database of supported brands"""
return [
"display",
"battery",
"connectivity",
"screen",
"keyboard",
"mouse",
"performance",
]
def validate_brand(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value.lower() in self.brands_db():
return {"brand": value}
else:
dispatcher.utter_message(template="utter_wrong_brand")
return {"brand": None}
def validate_part(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value.lower() in self.parts_db():
return {"part": value}
else:
dispatcher.utter_message(template="utter_wrong_brand")
return {"part": None}
def submit(self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]
) -> List[Dict]:
dispatcher.utter_message(template="utter_submit")
return []
stories.md:
happy path1
- greet
- utter_greet
- details_provider
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
- goodbye
- utter_goodbye
happy path2
- greet
- utter_greet
- issue_provider
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
- goodbye
- utter_goodbye
happy path3
- greet
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
- goodbye
- utter_goodbye
happy path4
- issue_provider
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
- goodbye
- utter_goodbye
happy path5
-
details_provider
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
-
goodbye
- utter_goodbye
happy path6
-
issue_provider
- issue_form
- form{ānameā: āissue_formā}
- form{ānameā: null}
- utter_slots_values
config.yml:
Configuration for Rasa NLU.
Components
language: en
pipeline: supervised_embeddings
Configuration for Rasa Core.
Policies
policies:
-
name: MemoizationPolicy
-
name: KerasPolicy
-
name: MappingPolicy
-
name: FormPolicy
nlu.md:
intent:greet
-
hey
-
hello
-
hi
-
good morning
-
good evening
-
hey there
intent:goodbye
-
bye
-
goodbye
-
see you around
-
see you later
intent:affirm
-
yes
-
indeed
-
of course
-
that sounds good
-
correct
intent:deny
-
no
-
never
-
I donāt think so
-
donāt like that
-
no way
-
not really
intent:bot_challenge
-
are you a bot?
-
are you a human?
-
am I talking to a bot?
-
am I talking to a human?
intent:details_provider
-
I have some difficulties with my laptop
-
I have some difficulties with my desktop
-
I have some difficulties with my mobile
-
There are some issues with my laptop
-
There are some issues with my desktop
-
There are some issues with my mobile
-
Some problems are there in my laptop
-
Some problems are there in my desktop
-
Some problems are there in my mobile
-
my laptop has some problems
-
my desktop has some problems
-
my mobile has some problems
-
some issues in my laptop
-
some issues in my desktop
-
some issues in my mobile
intent:issue_provider
-
my mobile connectivity is not working
-
my desktop connectivity is not working
-
my laptop connectivity is not working
-
my wearable connectivity is not working
-
screen is not working
-
display is not working
-
touch is not working
-
battery is not working
-
connectivity is not working
-
screen has issue
-
display has issue
-
touch has issue
-
battery has issue
-
connectivity has issue
-
screen has problem
-
display has problem
-
touch has problem
-
battery has problem
-
connectivity has problem
domain.yml:
intents:
- greet
- goodbye
- affirm
- deny
- bot_challenge
- details_provider
- issue_provider
entities:
- item
- brand
- part
slots: item: type: unfeaturized auto_fill: false brand: type: unfeaturized auto_fill: false part: type: unfeaturized auto_fill: false requested_slot: type: unfeaturized
templates: utter_ask_item:
- text: āwhatās your gadget?ā utter_ask_brand:
- text: āwhich brand?ā utter_ask_part:
- text: āwhich part?ā utter_greet:
- text: āHey! How are you?ā utter_did_that_help:
- text: āDid that help you?ā utter_goodbye:
- text: āByeā utter_iamabot:
- text: āI am a bot, powered by Rasa.ā utter_wrong_item:
- text: āwrong itemā utter_wrong_brand:
- text: āwrong brandā utter_wrong_part:
- text: āwrong partā utter_submit:
- text: āsubmitted thanksā utter_slots_values:
- text: āsubmitted your item: {item} of {brand}ā
actions:
- utter_greet
- utter_did_that_help
- utter_goodbye
- utter_iamabot
- utter_slots_values
forms:
- issue_form
Now my issue is,
1.i train with rasa train, then talk using rasa run actions & rasa shell,
Bot loaded. Type a message and press enter (use ā/stopā to exit):
Your input -> some issues in my mobile
whatās your gadget?
Your input -> some issues in my mobile
2020-01-03 16:10:09 ERROR rasa_sdk.endpoint - Failed to extract slot item with action issue_form
2020-01-03 16:10:09 ERROR rasa.core.actions.action - Failed to extract slot item with action issue_form
- after hello, I want sometimes bot ask about issue, sometimes itāll greet me back, how can I do this?