# Rasa form conditional logic

**URL:** <https://forum.rasa.com/t/rasa-form-conditional-logic/25523>\
**Category:** Rasa Open Source\
**Created:** [March 2, 2020, 4:32pm UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523 "2020-03-02T16:32:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali254](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ali254](https://forum.rasa.com/u/ali254)\
**Post date:** [March 2, 2020, 4:32pm UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/1 "2020-03-02T16:32:46Z")

</div>

I am trying to build conditional logic in my form where based on the response to the first question, different questions will be asked. I am trying to add decision tree like logic in my form. Is there any way to achieve this?

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [March 3, 2020, 8:48am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/2 "2020-03-03T08:48:35Z")

</div>

Yes, the required\_slots-method let’s you decide which slots you ask for. You can use conditional logic there.

There’s even a section in the docs

> **[Forms](https://rasa.com/docs/rasa/forms/)**
>
> Follow a rule-based process of information gathering using forms in open source bot framework Rasa.

---

<div class="post-metadata">

**Author:** ![ali254](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ali254](https://forum.rasa.com/u/ali254)\
**Post date:** [March 4, 2020, 7:20pm UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/3 "2020-03-04T19:20:01Z")

</div>

I want to go one step further than just basic conditional logic so can I change the following example:

```
@staticmethod
def required_slots(tracker) -> List[Text]:
   """A list of required slots that the form has to fill"""

   if tracker.get_slot('cuisine') == 'greek':
     return ["cuisine", "num_people", "outdoor_seating",
             "preferences", "feedback"]
   else:
     return ["cuisine", "num_people",
             "preferences", "feedback"]

```

so that it asks for cuisine as a slot during the form action and then decides to include outdoor seating or not - all during a form.

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [March 4, 2020, 8:45pm UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/4 "2020-03-04T20:45:47Z")

</div>

It does. The method is called every turn

---

<div class="post-metadata">

**Author:** ![ali254](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@ali254](https://forum.rasa.com/u/ali254)\
**Post date:** [March 5, 2020, 9:16am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/5 "2020-03-05T09:16:26Z")

</div>

ok awesome then thanks

---

<div class="post-metadata">

**Author:** ![Wy0024](https://avatars.discourse-cdn.com/v4/letter/w/57b2e6/32.png) [@Wy0024](https://forum.rasa.com/u/Wy0024)\
**Post date:** [March 30, 2020, 9:38am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/6 "2020-03-30T09:38:45Z")

</div>

Hi, is there a way to handle conditional logic either in Form or custom Action? I have in mind a scenario such as :

Prompt user relevant required slots based on slot values

1. required fields are A & B
2. If either of the two fields are not filled, lead them to fill up the slots by a form
3. If both of the fields are filled, trigger another custom action which eventually will ask user whether to edit and will reactivate the forms again with slots all being reset, if user decides to modify.

Any advise on how to tackle such scenario?

Much Appreciated

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [March 30, 2020, 9:42am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/7 "2020-03-30T09:42:28Z")

</div>

I don’t understand your scenario completely.

User enters slots A & B. Now you want to ask him, what to edit?

---

<div class="post-metadata">

**Author:** ![Wy0024](https://avatars.discourse-cdn.com/v4/letter/w/57b2e6/32.png) [@Wy0024](https://forum.rasa.com/u/Wy0024)\
**Post date:** [March 30, 2020, 9:48am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/8 "2020-03-30T09:48:40Z")

</div>

Sorry, let me give you a little bit more background on this.

So for the first time, user will need to enter slot A & B. But keep in mind that i allow user to detour at any point. For the next visit, user will then either required to fill up whichever slot that is yet to be filled, OR redirect to another action whereby i ask user whether they wanted to edit the two slot values that they provided previously.

Does this make any sense?

---

<div class="post-metadata">

**Author:** ![IgNoRaNt23](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/ignorant23/32/8029_2.png) [@IgNoRaNt23](https://forum.rasa.com/u/IgNoRaNt23)\
**Post date:** [March 31, 2020, 7:13am UTC](https://forum.rasa.com/t/rasa-form-conditional-logic/25523/9 "2020-03-31T07:13:54Z")

</div>

A little better, yes.

Why are you stuck with that?
