How does a FormAction know which template to ask

Below is my Story.

Happy Path 1

  • apply_leave{“start_datetime”: “tomorrow”, “end_datetime”: “day after tomorrow”, “leave_type”: “annual”}
    • apply_leave_form
    • form{“name”: “apply_leave_form”}
    • form{“name”: null}
    • action_utter_leave_confirmation_message
  • appraisal.good OR confirmation.yes
    • action_apply_a_leave
    • action_utter_leave_confirmed_message
    • utter_have_a_nice_day
    • action_slot_reset_except_employee_id

Able to find out the Intent and also properly extract the entities

Chat Conversation.

  • Me: Apply me a leave
  • Bot: // No Response Waiting for me to enter Reference Number, I want it to ask utter a template

In Rasa X

Story till now window

Chat with me

  • apply_leave
    • apply_leave_form
    • form{“name”:“apply_leave_form”}
    • slot{“requested_slot”:“reference”}

How can I register for a form which question to ask when it tries to request a slot.

If I’m understanding your problem, you’ll set this up in the file.

Inside your ApplyLeaveForm class look for (or add) the required_slots method.

You’ll want to do something like this (most of this is a guess because I don’t know what your utterances or actions, or templates are called)

    def required_slots(tracker: Tracker) -> List[Text]:
      requiredSlot = ["reference",.... other slots on your form ]
      return requiredSlot

in your domain.ymp file you’ll want to setup entities,slots, templates and actions all for that “reference” field you want the bot to ask for and collect

     - reference
     - reference
      - text: "Whatever you want to ask the user for reference"
 - utter_ask_reference

So basically you tell your form action which of the slots you have are required. And you setup those 4 entries in domain.yml. Retrain the bot and it should work. (I hope)

If not, post your and domain.yml file and I’ll take a look.

I believe in the required_slots, you should be returning a list of slot names rather than action names. In this example, [“reference”] rather than [“utter_ask_reference”,… other slots on your form ]. I think the answer is found in the docs here:

Every time the form action gets called, it will ask the user for the next slot in required_slots which is not already set. It does this by looking for a response called utter_ask_{slot_name} , so you need to define these in your domain file for each required slot.

ooops, you’re right - thanks for the correction, I’ve modified my code above.