Dynamic Single Choice
# 🤝help
t
Hello guys. My variable @workflow.stackAiResponse returns the Adresses from the user that are present in my database in airtable. Now I want to ask the user in a single choice card: "Which adress do you want to know more information? Adress 1 Adress 2" Somebody knows how can I do that? I think there is a issue because the client can either have 1 or 10 addresses If I knew that it will allways have 2 addresses I could create one variable for each address. However the user can have other number of variables that I do not know a priori

https://cdn.discordapp.com/attachments/1143907479718203403/1143907691396337805/Screenshot_2023-08-23_150031.png

f
Hello @tall-market-29797 this is currently not doable in cloud, but I recommend requesting this feature in the Feature-requests channel.
Ah ha, actually @tall-market-29797 I found out some wonderful information. I was wrong. You can do what you are looking to do. First, you will want to create an array in code. Just set the code to build the array based on the data coming in from your air table. Here is a screenshot of a hardcoded example.

https://cdn.discordapp.com/attachments/1143907479718203403/1144012290576883833/screenshot_2023-08-23_at_4.png

Then you will want to reference the variable in the super input in the choice skill

https://cdn.discordapp.com/attachments/1143907479718203403/1144012452321833141/screenshot_2023-08-23_at_4.png

Then as you test the bot you will see it render

https://cdn.discordapp.com/attachments/1143907479718203403/1144012645318529104/screenshot_2023-08-23_at_4.png

Please let me know if you have any other questions
q
It's really funny that this question came up today, I need this now too. Any idea why mine ain't workin'? The single choice is not looping through my array, instead it just prints '@workflow.myChoices' as the only option with the array being the capture value.
My array:

https://cdn.discordapp.com/attachments/1143907479718203403/1144123257084182558/image.png

How it's assembled:

https://cdn.discordapp.com/attachments/1143907479718203403/1144123351443447908/image.png

The single choice card itself:

https://cdn.discordapp.com/attachments/1143907479718203403/1144123562827984926/image.png

The array 'myChoices' printed in plain text as well as the final question as it appears in chat. Note: the single choice renders the variable, not the array contents :C

https://cdn.discordapp.com/attachments/1143907479718203403/1144123904223350784/image.png

have even gone so far as to replicate your example with the hardcoded array. Same result.
b
Yes but it wors only in the emulator. I am having issues doing the same on web chat as I can see the options but when I click the varible isn't captured...
f
Hello @quick-crowd-66671 and @busy-evening-56847 The first thing after looking at your screenshots is don't use the AI Task to do this. You need to use the execute code card. Make sure you have declared the array variable in the workflow as well.

https://cdn.discordapp.com/attachments/1143907479718203403/1144256111176851497/image.png

https://cdn.discordapp.com/attachments/1143907479718203403/1144256111453667348/image.png

https://cdn.discordapp.com/attachments/1143907479718203403/1144256111713730640/image.png

I am curious about your point of it not working in the webchat as I have been able to get to work with webchat as well.

https://cdn.discordapp.com/attachments/1143907479718203403/1144256957004398713/image.png

Can you clarify what you are doing with your webchat so we can help you troubleshoot?
q
Hey. I am now using the execute code card and its still defunct. the variable being defined in the execute code card:

https://cdn.discordapp.com/attachments/1143907479718203403/1144301912049598474/image.png

f
Have you created the array variable in the workflow?
q

https://cdn.discordapp.com/attachments/1143907479718203403/1144302119378223195/image.png

f
Perfect
Oh use single quote ' in the execute code card not double quotes " - Actually this really doesn't matter ignore this
q
oh really let me try.

https://cdn.discordapp.com/attachments/1143907479718203403/1144302390087000115/image.png

f
Show me a quick screenshot of your choice skill
please
q

https://cdn.discordapp.com/attachments/1143907479718203403/1144302667078836364/image.png

and same result with single quotes. Note. I too am using the webflow UI.
f
Oh there is the issue... delete the item there
then click the {x}
q
fixed!
okay. What's the difference between the x being clicked and not clicked?

https://cdn.discordapp.com/attachments/1143907479718203403/1144302981123153960/image.png

f
The X click is basically telling the bot the create the choices based on an array
I am sure there is much more technical answer, but that is how i think about it
q
wow. okay. thank you. thank you for your time!
f
No worries
Always happy to help
q
Note: while i'm NOT able to get the AI task card to format this in a way that works for the Single Choice card, (because it appears myChoices must be set to "Option" and not "String". AI Task seems to be only able to work with strings), I am able to get AI Task to put the choices into a list, then map that list into an array with a code block and that works just fine.

https://cdn.discordapp.com/attachments/1143907479718203403/1144306588337832059/image.png

https://cdn.discordapp.com/attachments/1143907479718203403/1144306680943886406/image.png

f
Cool
68 Views