If else flow - Rasa CALM - Rasa Community Forum
If else flow
post by adeelhasan19 on Jul 3, 2024
next:
- if: slots.has_taken_previous_medications
then: has_taken_previous_medications_id
- else: no_previous_medication_id
- id: no_previous_medication_id
action: utter_no_previous_medication_response
- id: has_taken_previous_medications_id
collect: user_previous_medications
Above is the code that I am using in the flow. Why both if and else conditions are getting executed?
post by jtrasa on Jul 3, 2024
Hello Adeel,
If a step in a flow does not have a next field, then Rasa executes the next step defined in the flow.
So from the flow steps defined above, step has_taken_previous_medications_id will always be run after step no_previous_medication_id.
More information can be found in the flow documentation.
post by adeelhasan19 on Jul 4, 2024
can you help in modifying the above code according to the flow in the image
post by jtrasa on Jul 8, 2024
Sure, this adds empty_step as a place for no_previous_medication_id to jump to,
to skip step has_taken_previous_medications_id:
next:
- if: slots.has_taken_previous_medications
then: has_taken_previous_medications_id
- else: no_previous_medication_id
- id: no_previous_medication_id
action: utter_no_previous_medication_response
next: empty_step
- id: has_taken_previous_medications_id
collect: user_previous_medications
- id: empty_step
noop: true