Create a Conditional Form

I need to have a Form to ask for different slots based on the answers captured and stored in a slot, for example:

1st Question: Printer Type - slot that can be either shared or personal

Personal Printer Path 2nd Question Restart Printer, Did it work (y/n) - if answer is no, then 3rd Question else ‘Great!’ 3rd Question Restart Computer, Did it work (y/n) - if answer is no ‘Sorry’ else ‘Great!’

Shared Printer Path 2nd Question: Does anyone else has the same issue (y/n) - if answer is yes 3rd Question else 4th Question 3rd Question: Restart Computer, Did it work (y/n) - if answer is yes then ‘Great’ else ‘Sorry!’ 4th Question: Restart Printer, Did it work (y/n) - if answer is yes then Great else ‘Sorry’

I have tweaked the required_slots method for the PrinterFail class, but once it starts asking the slot data, I cannot delete an entry from the required_slots list, I have enclosed the actions and domain files as a reference.

Any ideas on how to go about it? (26.9 KB) domain.yml (9.0 KB)

You’re on the right path with changing the required_slots method. I’m not sure what you mean with “I cannot delete an entry from the required_slots list” - it looks like your code is doing that? What is happening instead?

I think you could simplify your action by starting with all the slots, and only removing them as necessary, as opposed to re-calculating the list every time the method is called. For example (haven’t tested it):

    def required_slots(tracker: Tracker) -> List[Text]:
        req_slots = [
                "printer_type", "anyone_else", "poweroff_printer", "poweroff_pc"

        # Personal Printer Path
        if tracker.get_slot("printer_type") == 'PERSONAL':
            if tracker.get_slot("poweroff_printer") is False:
        # Shared Printer Path
        if tracker.get_slot("printer_type") == 'SHARED':
            if tracker.get_slot("anyone_else") is False:

        return req_slots


Thanks for your response, it is to my understanding that after a slot in the required_slots list is filled, the required_slots method is executed, in order to refresh the list, opening the possibility to add logic that can change the filling methods behavior.

However, when I had the logic set as you saw, it worked only the first time, based on the subsequent entries there were other slots that needed to be added or removed from that list, but it ignored the conditionals in the code.

I ended up using the validate methods to fill those slots through code with values other than None, so the form processor would not ask for them, I will revisit the required_slots method logic to make sure all slots are on the list, and add logic to ensure that, based on the data collected, some of those slots get removed from the required_slots list.

Again, thanks for taking the time to look at the code and providing feedback on this item.