Custom Confirmation of FormAction

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),]

So its my second topic without replies. Are my questions too complicated or has nobody tried something like that before? I reduced the form example above to only 4 requested slots. My original document, that I want to fill with the bot, has over 20 entries. Is the Rasa Stack unable to do something like that, slot filling and confirmation for everything?

I tried to achieve a solution in many different ways, but in the end I have to say, it took me only a few hours to read and understand the IBM Watson Assistant documentation and to realize what i needed.

in domain file, you can do something like:

templates:
	utter_ask_confirm:
		- text: 'Please check your data: Start Date: {StartDate}, End Date: {EndDate}, Costs: {Cost}'
		  buttons:
		  	- title: 'Abbrechen'
		  	  payload: 1
		  	- title: 'Speichern'
		  	  payload: 2
		  	- title: 'Einreichen'
		  	  payload: 3

then in FormAction, validate function maybe you can do something like:

	def validate(dispatcher, tracker, domain):
		slot_to_fill = tracker.get_slot(REQUESTED_SLOT)
		if slot_to_fill == 'confirm':
			if slot_val == 1:
				return FollowupAction(name=ActionToPerform)]
			elif slot_val == 2:
				return FollowupAction(name=ActionToPerform)]
			elif slotval == 3:
				return FollowupAction(name=ActionToPerform)]
1 Like

Thanks for your reply. I like to get the slots data as json with dispatcher.utter_attachment, so I can choose different display styles in frontend and not just plain text. As I said in my second post, my document has over 20 slots. It looks better in a table. So I need to run an custom action if requested slot ist ‘confirm’ and not utter_ask_confirm.