So i’m developing a bot with rasa 2.0 using slots and forms. When i run the bot everything runs well, all the form fields work but the data is not saved to a database on submit. The bot does tell me the data that ive put in the form but the actions.py function does not submit the data to database. What could be the problem?
Actions.py
class ActionFormInfo(FormAction):
def name(self) -> Text:
"""Unique identifier of the form"""
return "request_names"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
"""A list of required slots that the form has to fill"""
return ["first_name", "your_email","recipient","message"]
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict]:
"""Define what the form has to do
after all required slots are filled"""
# utter submit template
dispatcher.utter_message(template="utter_submit", first_name=tracker.get_slot('first_name'),
your_email=tracker.get_slot('your_email'),recipient=tracker.get_slot('recipient'),
message=tracker.get_slot('message'))
mail = requests.post('http://localhost:8000/api',{'first_name':first_name,'your_email':your_email,'recipient_mail':recipient,'message':message}).json()
print(""" You submited the information {} {} {} {}""")
return []
def slot_mappings(self) -> 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 {
"first_name": self.from_entity(entity="first_name", intent='my_name_is'),
"your_email": self.from_entity(entity="your_email", intent="email"),
"recipient": self.from_entity(entity="recipient", intent="recipient_mail"),
"message": self.from_entity(entity="message", intent="message"),
}