# FormAction ask for different slots based on user input?

**URL:** <https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688>\
**Category:** Rasa Open Source\
**Created:** [August 22, 2019, 4:31pm UTC](https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688 "2019-08-22T16:31:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alihejazi](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@alihejazi](https://forum.rasa.com/u/alihejazi)\
**Post date:** [August 22, 2019, 4:31pm UTC](https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688/1 "2019-08-22T16:31:55Z")

</div>

Hi all, hope you’re having a lovely day.

I am facing a slightly intricate problem, but I will explain it as simple as possible:

I have a FormAction used for authentication and takes in multiple credentials from the user.

credential1 and credential2 are mandatory, but then the user has the option to choose credential3 or credential4 as their final credential to authenticate.

These are the credentials the bot should ask for: consumer id (cid) -\> this is credential1 pin code -\> credential2 ssn code -\> credential3 phone number -\> credential4

So, cid and pin are mandatory, but only one of ssn and phone number is needed.

Whether the bot asks for the ssn code or the phone number is based on user input after entering the consumer id and pin code.

How do I model this in a form action?

Basically the trouble I’ve been having is changing the list returned by the required\_slots() method, based on the user input to choose the ssn code or phone number, half way through the form action.

Alternatively, if there’s a much better and cleaner approach, please let me know.

Many thanks in advance, and happy coding!

Ali.

---

<div class="post-metadata">

**Author:** ![fuih](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fuih](https://forum.rasa.com/u/fuih)\
**Post date:** [August 23, 2019, 1:59am UTC](https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688/2 "2019-08-23T01:59:45Z")

</div>

> [@alihejazi](#):
>
> Basically the trouble I’ve been having is changing the list returned by the required\_slots() method, based on the user input to choose the ssn code or phone number, half way through the form action.

Well i think that’s not a bad way to do it.

You can ask the user: “Please choose 1 of these 2 credentials that you wish to provide” and prepare an intent inform\_credential with a corresponding credential slot for it. After that i can think 2 of directions:

1. Manipulate the requested\_slots (what you are trying to do):

2. Using validate\_{slot\_name}:

---

<div class="post-metadata">

**Author:** ![alihejazi](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@alihejazi](https://forum.rasa.com/u/alihejazi)\
**Post date:** [August 23, 2019, 1:46pm UTC](https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688/3 "2019-08-23T13:46:25Z")

</div>

Thanks for your response @fuih. I decided to do it by defining the final credential(s) needed with a setup script which creates a configuration file read in by actions.py.

---

<div class="post-metadata">

**Author:** ![Gehova](https://avatars.discourse-cdn.com/v4/letter/g/2acd7d/32.png) [@Gehova](https://forum.rasa.com/u/Gehova)\
**Post date:** [August 28, 2019, 3:35pm UTC](https://forum.rasa.com/t/formaction-ask-for-different-slots-based-on-user-input/14688/4 "2019-08-28T15:35:50Z")

</div>

A more easy solution for your case is to replace the slots “ssn” and “phonenumber” with a single slot “number” and ask something like 'Write your ssn or phone number" and validate it in the submit method of the form, because the ssn has 9 digits and the cellphone has 10.
