How to confirm forms slots

I’m trying to create a form to set an appointment where the user is prompted to confirm the appointment once the appointment_type and time slots are filled.

This is my form in the domain.yml

  appointment_form:
    appointment_type:
      - type: from_text
        entity: appointment_type
        intent: inform
    time:
      - type: from_text
        entity: time
        intent: inform

then I added two stories, one for the happy path and one for the unhappy path in which the user doesn’t confirm. I’ve done this through stories as I want to use custom actions at different points:


- story: new appointment happy path
  steps:
  - active_loop: appointment_form 
  - slot_was_set:
    - appointment_type: mri
  - slot_was_set:
    - time: "2020-11-11T12:00:00.000-08:00"
  - action: validate_appointment_form
  - intent: affirm 
  - action: save_appointment_to_db

- story: new appointment unhappy path 0 
  steps:
  - active_loop: appointment_form 
  - slot_was_set:
    - appointment_type: mri
  - slot_was_set:
    - time: "2020-11-11T12:00:00.000-08:00"
  - action: validate_appointment_form
  - intent: deny
  - action: clear_appointment_form

I think the two stories are conflicting as if I have a custom action clear_appointment_form at the end of the unhappy story, neither of the two stories works (the custom action only prints a message to the user for now). However if I have - action: utter_greet instead of the action aat the end of the story the two work as expected.

What am I doing wrong? Are happy paths for forms something that was deprecated or is this the correct way of using a form happy path?

Hi @laujen I think you can do this

  1. on your custom actions, in the required slots add one more “confirm”
  2. then create a slot map function to receive the confirmation or denial from the user
  3. On your domain add, user_ask_confirm with buttons to make sure the user either affirms or denies

I hope it helps.

Eden

Summary

on your custom actions, in the required slots add one more “confirm”

@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""

    ##TODO: define required slots
    return ["your_slot", "your_slot", "confirm"]

then create a slot map function to receive the confirmation or denial from the user

def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:  

    return {
 
        "confirm": [
            ##TODO: set the slot mapping for the slot "confirm" based on the intent value
            self.from_intent(value = True, intent="affirm"),
            self.from_intent(value = False, intent="deny")
        ],
    }

On your domain add, user_ask_confirm with buttons to make sure the user either affirms or denies

  utter_ask_confirm:
  - buttons:
    - payload: /affirm
      title: Yes
    - payload: /deny
      title: No, cancel the appointment
   text: "are you sure you want to book the appointment"

thanks @jusce17 I was thinking of that but wasn’t sure if it was the way to do it or a sort of “workaround” I’ll try it out thanks!