Activate a form only if another form's certain slot value is set

Hi,

I am trying to write stories covering emotion care services with several forms. What I want is to activate serious_emotion_form only if the scale_emotion_form's emotion_score value is set to 10; otherwise, I want the listen_cause_form to follow scale_emotion_form without serious_emotion_form activation. For them, created stories as described below:

- story: Intense angry
  steps:
# Emotion detection
  - intent: intent_psychological_anger
  - action: utter_empathy_badmood
# Scale emotion score
  - action: scale_emotion_form
  - active_loop: scale_emotion_form
  - slot_was_set:
    - emotion_score: 10
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
# If the score is high, start a psychological test
  - action: action_emotion_scale
  - action: serious_emotion_form
  - active_loop: serious_emotion_form
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: action_serious_emotion_result
# Ask why they feel in that way
  - action: listen_cause_form
  - active_loop: listen_cause_form
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: utter_end

- story: Mild anger
  steps:
# Emotion detection
  - intent: intent_psychological_anger
  - action: utter_empathy_badmood
# Scale emotion score
  - action: scale_emotion_form
  - active_loop: scale_emotion_form
  - slot_was_set:
    - emotion_score: 3
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
# Ask why they feel in that way
  - action: listen_cause_form
  - active_loop: listen_cause_form
  - active_loop: null
  - slot_was_set:
    - requested_slot: null
  - action: utter_end

However, only the Intense angry story works regardless of the value of emotion_score. Is there any mistake I made here? Please let me know how to write a proper story to activate a form only if another form’s slot value is set. Any help would be greatly appreciated. Thanks.

You can customize your forms like Custom Actions (see Forms - Advanced Usage).

In particular, you can override required_slots() to return an empty list if emotion_score is 10:

class ValidateSeriousEmotionForm(FormValidationAction):
    def name(self):
        return 'serious_emotion_form'

    async def required_slots(self, slots_mapped_in_domain, dispatcher, tracker, domain):
        if str(tracker.slots.get('emotion_score')) == '10':
            return []
        return slots_mapped_in_domain

Thanks a lot! When changing serious_emotion_form to validate_serious_emotion_form and set it to the domain file, it works!