https://discord.gg/botpress logo
Dynamic items in Multiple Choice
# 🤝help
a
I want to get timeslots from my timetable. And show them as buttons in Multiple choice. How can I do this? I know only how to create buttons explicitly.

https://cdn.discordapp.com/attachments/1146908204035473458/1146908204152926313/image.png▾

f
Hey while setting up a choice input card you can choose to create the options from a variable of type array

https://cdn.discordapp.com/attachments/1146908204035473458/1146909177537638430/image.png▾

https://cdn.discordapp.com/attachments/1146908204035473458/1146909229479895040/image.png▾

In the screenshots above,
workflow.Options
is an array
Then you can use an execute code card to fetch time slots from wherever and set the variable to have dynamic options
a
Works like charm. Thank you, @freezing-elephant-85019 !
@freezing-elephant-85019 , is there a common way to route these results? Let's say the choice is 15:00, is there a common way to process this choice?
f
What do you mean by a common way?
Are you familiar with javascript? or coding?
it depends on what you want to do with the selection afterwards. Let's say `"15:00" `is selected, you can send it to your service as it is (as a
string
) to book a slot, or format that as a valid date string and then process it. The latter would be considered ideal (or common) if that's what you mean
a
Thank you. I mean, in pre-input choices, I can attach arrows to every choice and process them. In this dynamic choice I have no exits in the node. I guess, I can use a code card and process the choice programmatically, and then use "always" router to move further
f
if by processing, you mean you want to add unicode arrows
→
or emojis, you can
a
Thank you! Will try working on that
20 Views