I'm trying to learn Bot Framework using .Net and I have an application which displays buttons and based on the option selected, display more buttons or a list. What I want is, to send a hidden ID/parameter with the button so that when user clicks on the button, I can access the hidden parameter. I'm not using cards for this. I just want to display the buttons. Can anyone help me with this? I know this can be a very basic question but I couldn't find how to this without Cards.
- What channel are u using?Ezequiel Jadib– Ezequiel Jadib2017-03-30 09:44:09 +00:00Commented Mar 30, 2017 at 9:44
- I'm just using the Channel EmulatorCuriosity– Curiosity2017-03-30 12:29:02 +00:00Commented Mar 30, 2017 at 12:29
- How you are creating/sending the buttons if you are not using cards?Ezequiel Jadib– Ezequiel Jadib2017-03-30 12:33:04 +00:00Commented Mar 30, 2017 at 12:33
- By using PromptDialog.Choice()Curiosity– Curiosity2017-03-30 12:34:15 +00:00Commented Mar 30, 2017 at 12:34
1 Answer
First of all, PromptDialog.Choice behind the scenes creates a HeroCard with multiple buttons (which are basically the PromptOptions passed, see the code)
One way to pass a hidden parameter would be specifying the ActionType PostBack to your button and fill the Value property with the hidden parameter. PostBack is the way to go here since the message will be posted to the bot but client applications will not display this message (however, please note that not all the channels support the postBack action type). See this for more information
Now, since you are using PromptDialog.Choice you will have to override things in order to be able to specify the PostBack action type, since by default, the buttons created with the Choice are using ImBack (per this code)
You will have to put together a custom PromptStyler, override the Apply<T> method and add your logic to change the action type and set the buttons in the way you want based on the PromptStyle used and pass that custom styler to the PromptDialog.Choice.
By default the PromptDialog.Choice uses PromptStyle.Auto.
2 Comments
IReadOnlyList<T>). It would be really helpful if you can explain that a bit more. But otherwise, I'll try a bit more.