I want a custom confirmation in my form at the end. If the slots are filled, all data should be displayed in the chat UI and also 3 Buttons “Cancel”, “Save”, “Submit”. If clicked one, the last requested_slot “Confirm” will be filled and the action_complete_form should run. The problem is, that a requested_slot call utter_ask_{slot_name} in domain file. Is it possible to run custom actions if requested_slot is set or can i set the attachment in domain file with the filled slots?
* create_new_request
- form_create_new_request
- form {"name": "form_create_new_request"}
- slot {"requested_slot": "StartDate"}
* inform{"StartDate": "15.03.2019"}
- slot {"StartDate": {"data": "2019-03-15", "type":"datetime"}}
- slot {"requested_slot": "EndDate"}
* inform {"EndDate": "27.03.2019"}
- slot {"EndDate": {"data": "2019-03-27", "type": "datetime"}}
* inform {"Costs": 245}
- slot {"Costs": 245}
- action_ask_confirmation {"requested_slot": "Confirm"}
* inform {"Confirm": 1}
- slot {"Confirm": 1}
- action_complete_form
- form {"name": null}
- slot {"requested_slot": null}
class ActionConfirm(Action):
def name(self):
return 'action_ask_confirmation'
def run(self, dispatcher, tracker, domain):
slots = {
'StartDate': tracker.get_slot('StartDate'),
'EndDate': tracker.get_slot('EndDate'),
'Costs': tracker.get_slot('Costs')
}
buttons = {
'title': 'Please check your data.',
'options': [{'label': 'Abbrechen', 'value': '1'},
{'label': 'Speichern', 'value': '2'},
{'label': 'Einreichen', 'value': '3'}]
}
dispatcher.utter_attachment({'buttons': buttons, 'slots': slots})
return []
class ActionComplete(Action):
def name(self):
return 'action_complete_form'
def run(self, dispatcher, tracker, domain):
confirm = tracker.get_slot('Confirm')
slots = {
'StartDate': tracker.get_slot('StartDate'),
'EndDate': tracker.get_slot('EndDate'),
'Costs': tracker.get_slot('Costs')
}
if confirm == 1
# end form
elif confirm == 2
# something to save slots
elif confirm == 3
# something to submit slots
return [SlotSet('StartDate', None),SlotSet('EndDate', None),SlotSet('Costs', None),]