Rasa Core version: 0.13.2
Python version: 3.6.8
Operating system (windows, osx, …): Windows
Issue: My chitchat does not work correctly. The main goal of my chatbot is to fill the required slots (name, birthday, product type and customer number). In between the slot filling process, it is possible that the customer is writing chitchat. Therefore I need a story that can handle this case. However, this doesn’t work properly. When writing chitchat, it is populating my slots.
Possible reasons: The story “story_form_unhappy_path” doesn’t work. According to Slot Filling I need an ActionExecutionRejection (not included in the example because it is not working) in the actions.py file (usualy in the validation function). See here: rasa_core/actions.py at master · RasaHQ/rasa_core · GitHub
My question: Can you please tell me what is going wrong in my code? How can I stop chitchat from populating my slots?
My code:
stories.md
## story_greet_happy_path
* greet
- utter_introduction
- utter_education
> check_education <!--- setting a checkpoint -->
## story_form_happy_path
> check_education
- authenticate_form
- form{"name": "authenticate_form"} <!--- start form -->
- slot{"name": "Sam Johns"} <!--- asking for name -->
- slot{"product": "credit"} <!--- asking to choose a button -->
- slot{"birthday": "01.01.1979"} <!--- asking for birthday -->
- slot{"contract_no": "123457890"} <!--- asking for contract number -->
- form{"name": null} <!--- finish form -->
> check_summary
## story_form_unhappy_path
> check_education
- authenticate_form
- form{"name": "authenticate_form"} <!--- start form -->
* chitchat
- utter_chitchat
- slot{"name": "Sam Johns"} <!--- asking for name -->
- slot{"product": "credit"} <!--- asking to choose a button -->
- slot{"birthday": "01.01.1979"} <!--- asking for birthday -->
- slot{"contract_no": "123457890"} <!--- asking for contract number -->
- form{"name": null} <!--- finish form -->
> check_summary
## story_summary
> check_summary
- utter_summary_name
- utter_summary_birthday
- utter_summary_contract_no
## story_bye
* bye
- utter_bye
train.md
## intent:bye
- by
- see you
- goodby
## intent:greet
- hi
- good morning
- hello
## intent:thank
- thanks
- thank you
- thank you very much
## intent: chitchat
- how is the weather?
- how old are you?
- you are stupid!
## intent:contract_no
- [1234567890](contract_no)
- this is my contract numer [0987654321](contract_no)
- here is my contract number [0987654321](contract_no)
domain.yml
intents:
- greet
- bye
- thank
- chitchat
- contract_no
entities:
- name
- product
- birthday
- contract_no
slots:
name:
type: unfeaturized
product:
type: categorical
values:
- credit
- account
birthday:
type: unfeaturized
contract_no:
type: unfeaturized
actions:
- utter_ask_name
- utter_ask_birthday
- utter_ask_contract_no
- utter_thank
- utter_bye
- utter_form_bye
- utter_introduction
- utter_education
- action_default_fallback
- utter_summary_name
- utter_summary_birthday
- utter_summary_contract_no
- utter_chitchat
forms:
- authenticate_form
templates:
utter_introduction:
- text: "Hi I am your chatbot"
utter_education:
- text: "I need some informations about you."
utter_ask_name:
- text: "What is your name (first and last name)?"
buttons:
- title: "first Nachname"
payload: "name"
utter_ask_birthday:
- text: "Was ist Ihr Geburtsdatum?"
buttons:
- title: "tt.mm.jjjj"
payload: "birthday"
utter_ask_product:
- text: "Um welches Produkt geht es?"
buttons:
- title: "Kredit"
payload: '/product{"product": "credit"}'
- title: "Konto"
payload: '/product{"product": "account"}'
utter_ask_contract_no:
- text: "What is your contract number?"
buttons:
- title: "0123456789"
payload: "contract_no"
utter_bye:
- text: "Thank you {name}. I will forward you to an {product} expert"
utter_form_bye:
- text: "Thank you for providing your informations"
utter_summary_name:
- text: "Your name: {name}"
utter_summary_birthday:
- text: "Your birthday: {birthday}"
utter_summary_contract_no:
- text: "Your contract number: {contract_no}"
utter_thank:
- text: "You are welcome"
utter_chitchat:
- text: "Sorry, I do not speak chitchat."
actions.py
from rasa_core_sdk.forms import FormAction
class AuthenticateForm(FormAction):
"""Example of a custom form action"""
def name(self):
# type: () -> Text
"""Unique identifier of the form"""
return "authenticate_form"
@staticmethod
def required_slots(tracker):
# type: () -> List[Text]
"""A list of required slots that the form has to fill"""
return ["name", "product", "birthday",
"contract_no"]
def submit(self, dispatcher, tracker, domain):
# type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict]
"""Define what the form has to do
after all required slots are filled"""
# utter submit template
dispatcher.utter_template('utter_form_bye', tracker)
return []
def slot_mappings(self):
# type: () -> Dict[Text: Union[Dict, List[Dict]]]
"""A dictionary to map required slots to
- an extracted entity
- intent: value pairs
- a whole message
or a list of them, where a first match will be picked"""
return {
"name": [self.from_entity(entity="name")],
"product": [self.from_entity(entity="product")],
"birthday": [self.from_entity(entity="birthday")],
"contract_no": [self.from_entity(entity="contract_no")],
}