Stop form from being activated

Hi,

I only want to start my form if a specfic slot is set to True.

Here are my rules:


- rule: Start Form
  condition:
    - active_loop: null
  steps:
  - intent: A
  - action: action_A_before
  - slot_was_set:
    - A_start: True
  - action: A_form
  - active_loop: A_form

- rule: No start of form
  condition:
    - active_loop: null
  steps:
  - intent: A
  - action: action_A_before
  - slot_was_set:
    - A_start: False
  - action: utter_no_A

Example:

  1. intent A
  2. action_A_before cecks whether the conditions are fulfilled or not and sets the A_start (True/False)
  3. if A_start == True → start form else dont start form

If I try it this way, i´ll get an “Contradicting rules or stories found” error, because of the last action in each rule.

Does anyone have an idea how to do this? (I can´t split it into a second intent) Thanks!

You can use a Custom Form Validation Action’s required_slots() method to check for that form and act accordingly:

class ValidateAForm(FormValidationAction):
    def name(self) -> Text:
        return 'A_form'

    async def required_slots(self, domain_slots, dispatcher, tracker, domain):
        if tracker.slots.get('A_start'):
            return domain_slots
        else:
            dispatcher.utter_message('You cannot start this form')
            return []
1 Like