How to deal with multiple if statements for action outcomes

Hi All -

Hoping someone can point me in the right direction.

In my app, I allow users to provide or not provide various information about themselves (i.e First Name, Last Name, Age, Email, Phone Number, etc…). I then have an action that takes all of this information and sends it in a prompt to OpenAI - example if someone provides all of their information would look like “Hi, my name is and I am years old. My email is and my phone number is .”

However, if a user doesn’t provide all of that information, the prompt could potentially end up looking like, “Hi, my name is John and I am years old. My email is and my phone number is .”

I want to setup my action to only include the dynamic fields that are saved for the user, but if I do it where I use the ‘Only When’ I would possibly have 32 different options with just the example I gave above (2x2x2x2x2=32). What’s the best way to solve for this without having to create 32 different actions with different ‘only when’ statements.

Thanks,

Hi @anthony.woodard91 :wave:

The best way to do it is creating your sentence step by step using “formatted as text” to outcome the result based on the filled information.

Promt = Hi CurrentUser's Name is empty:formatted as text, CurrentUser's Years is empty :formatted as text. CurrentUser's Email is empty:formatted as textand CurrentUser's Phone is empty:formatted as text.

CurrentUser's Name is empty:formatted as text
If Yes = leave empty
If No = “my name is Rafael”

CurrentUser's Years is empty :formatted as text
If Yes = leave empty
If No = “and I am 38 years old”

CurrentUser's Email is empty:formatted as text
If Yes = “I don’t have an email”
If No = “My email is xxxx@gmail.com

CurrentUser's Phone is empty:formatted as text
If Yes = “and I don’t have a phone number”
If No = “and my phone is +552199999999”

So, if the user gives you just his Name (Rafael) and his phone (+552199999999), the Promt will be:

Hi, my name is Rafael. I don’t have an email and my phone is +552199999999.

Hope it helps

2 Likes

Thank you - I’ll give this a try, but seems like exactly what I’m looking for.

To test my understanding, essentially I’m building the prompt pieces within the formatted as text function rather than with 'Only When’s

Thanks!

1 Like