# Form Based on Slot value

**URL:** https://forum.rasa.com/t/form-based-on-slot-value/50307
**Category:** Rasa Open Source
**Created:** [December 28, 2021, 9:57am UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307 "2021-12-28T09:57:46Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)
#### Post date: [December 28, 2021, 9:57am UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/1 "2021-12-28T09:57:46Z")

</div>

HI , This is my 2nd post in rasa 🙂 .

I have a scenario

1. User asks the bot to create Requisition order: _“Can you help me to create Purchase requisition order for ABCD1”_
2. Bot recognizes ABCD1 as item code. & this is mapped to a slot[item].
3. What if a user only says _“Can you help me to create a Purchase requisition order”_ in This case, the bot should ask for Item number & quantity.

Is there any way this can be achieved? Can forms be used to trigger based on slot value? i.e if slot[item] = ‘null’ then call item form else only call quantity form ?

Or is there a better way?

Regards, Mayank Pande

---

<div class="post-metadata">

### Author: ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)
#### Post date: [December 28, 2021, 4:20pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/2 "2021-12-28T16:20:16Z")

</div>

> [@mayank2288](#):
>
> forms be used to trigger based on slot value

Hello @mayank2288 and that’s a very tricky questions and personally I not implemented but I’m trying to give some pointers, please cross check with doc and some other threads too.

1. You need to use FormValidation, check the example mention in Rasa Doc: [Forms](https://rasa.com/docs/rasa/forms/#validating-form-input) how in this example we are matching the slot value and return the response, that you can archived whilst using If else statement with return. If the slot value match it will return else trigger the new form action.

2. In your else statement, you can trigger the new form using Followup Action, please see this thread: [Activating form action inside another form action indirectly leads to an error · Issue #215 · RasaHQ/rasa-sdk · GitHub](https://github.com/RasaHQ/rasa-sdk/issues/215) even you can play around with intents and entities for the same.

**Scenario 1:**

User: Can you help me to create Purchase requisition order for [ABCD1]

Bot: Sure let me see from my record please

Bot: ABCD1 here it Item code

**Scenario 2:**

User: Can you help me to create a Purchase requisition order

Bot: Sure! Which Item number number you want to order and how much quantity.

Bot: Please give me a detail for : 1. Item Number 2. How much quantity

User: ABZY2 and 5 qt

In this scenario we will trigger the Followup action with form.

**Note:** This is only my suggestion, as I told you I not implemented this use case and such scenario. Please think and implement as per your requirement.

I hope this will help you.

---

<div class="post-metadata">

### Author: ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)
#### Post date: [December 29, 2021, 8:19am UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/3 "2021-12-29T08:19:30Z")

</div>

Thanks, Nik202. This helped me.

What I did was to create the form

```auto
forms:
  requisition_form:
    required_slots:
        - item
        - itemqty
        - moreline

```

& slot as

```auto
slots:
  item:
    type: text
    influence_conversation: true
    mappings:
    - type: from_entity
      entity: item

```

What happens is that if an entity is not recognized by Bot, then the bot asks for these values from the user. This is working as expected.

But now If the user says (3rd Slot) that additional lines need to be added. In this case, is there any way to store existing values in the list & retrigger form to capture new lines?

Regards, Mayank Pande

---

<div class="post-metadata">

### Author: ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)
#### Post date: [December 29, 2021, 11:22am UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/4 "2021-12-29T11:22:17Z")

</div>

> [@mayank2288](#):
>
> But now If the user says (3rd Slot) that additional lines need to be added. In this case, is there any way to store existing values in the list & retrigger form to capture new lines?

Not get you at all on this, can you share some scenario or screenshot of bot/user?,and What is this moreline (adding new line? next line? is that what you meant ??

---

<div class="post-metadata">

### Author: ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)
#### Post date: [December 29, 2021, 12:55pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/5 "2021-12-29T12:55:27Z")

</div>

Yes Nik. I want Bot to ask user if new lines needs to be created. If user confirms than same form should be called to collect information.

I am not able to figure out this part.

Regards, Mayank

---

<div class="post-metadata">

### Author: ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)
#### Post date: [December 29, 2021, 1:10pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/6 "2021-12-29T13:10:33Z")

</div>

> [@mayank2288](#):
>
> I want Bot to ask user if new lines needs to be created

What is the significance of the new line? How you display in the chatbot also imagine how it will look like, can you share some example, I even asked you in my previous post. Thanks.

---

<div class="post-metadata">

### Author: ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)
#### Post date: [December 29, 2021, 3:56pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/7 "2021-12-29T15:56:58Z")

</div>

HI Nik202, Sorry for missing previous post.

Lets take example of Ticket Booking services.

```auto
User: I want to book ticked from Mumbai to Delhi.
Bot: Sure, I can cehck available flights from Mumbai to Delhi. Can you share passenger names?
Bot: First Name?
User: Mayank
Bot: Last Name?
User: Pande
Bot: Age of Mayank Pande
User: 33
Bot:any other traveler?
User: Yes , 2 more.

```

In this case, i want same form for First name, Last name & age should be repeated twice. or is there any better way to achieve this??

I hope it’s clear.

Regards, Mayank Pande

---

<div class="post-metadata">

### Author: ![nik202](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/nik202/32/16098_2.png) [@nik202](https://forum.rasa.com/u/nik202)
#### Post date: [December 29, 2021, 4:14pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/8 "2021-12-29T16:14:46Z")

</div>

@mayank2288 please can you confirm me that its related to the original issue which you mentioned in the topic, is that issue resolved?

@mayank2288 you asked me for the newline? where that concept vanish? me confused now 🤔

Always mention @ and nik202 for fast reply Thanks.

---

<div class="post-metadata">

### Author: ![mayank2288](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mayank2288/32/18756_2.png) [@mayank2288](https://forum.rasa.com/u/mayank2288)
#### Post date: [December 29, 2021, 4:30pm UTC](https://forum.rasa.com/t/form-based-on-slot-value/50307/9 "2021-12-29T16:30:03Z")

</div>

@nik202 : Thanks. I was not aware of ‘@’ issue is still there. I just tried to explain issue in generic terms. As my original issue is Procurement domain specific.

That’s why I tries to expain similar issue with gerniric use case,

Basically , I need to create order. One Order can have multiple lines. I have created form to capture information for lines. But I need form to repeat till User says that all lines are finished. .

In above example: User wants to book ticket for 3 persons(_line in my case_). Bot should ask First name, Last name & Age 3 times to user.

Regards, Mayank Pande
