I’m curious how to build some complex form logic and specifically when and how often the required_slots
method is called.
I have a few nested yes/no questions that lead down different paths and I’m having a problem with a nested if statement.
here’s is my required_slots
function
def required_slots(tracker: Tracker) -> List[Text]:
if (tracker.get_slot("erms_revoked") is None or tracker.get_slot("erms_revoked") == "Yes"):
requiredSlot = ["erms_revoked","erms_document_number","erms_manifest_number","erms_nsn","erms_error_number","erms_screenshot","erms_uic","erms_username","erms_expired", "erms_other_information"]
else:
if (tracker.get_slot("erms_requesting_access") is None or tracker.get_slot("erms_requesting_access") == "Yes"):
requiredSlot = ["erms_requesting_access", "erms_which_access"]
if (tracker.get_slot("erms_which_access") is None or tracker.get_slot("erms_which_access") == "NITA"):
requiredSlot = ["erms_which_access","erms_existing_user"]
else:
requiredSlot = []
else:
requiredSlot = ["erms_document_number","erms_manifest_number","erms_nsn","erms_error_number","erms_screenshot","erms_uic","erms_username"]
return requiredSlot
Here’s a rundown of what happens
if erms_revoked == Yes
, everything runs fine because it is one path to the end
If erms_revoked == No
, the else section executes
But inside the big else section, I’m expecting it to prompt with erms_requesting_access
, but I am never asked erms_requesting_access
, it jumps down and prompts erms_which_access
My many questions:
- when does required_slots run? once or multiple times through the form?
- should it work this way?
- is there a better / different way to structure something like this?