1

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.

4
  • What channel are u using? Commented Mar 30, 2017 at 9:44
  • I'm just using the Channel Emulator Commented Mar 30, 2017 at 12:29
  • How you are creating/sending the buttons if you are not using cards? Commented Mar 30, 2017 at 12:33
  • By using PromptDialog.Choice() Commented Mar 30, 2017 at 12:34

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much for the clear explanation. I could learn a lot I didn't know. I tried to do as you have said above. But I cannot understand how to pass values to the custom styler, specially the options (IReadOnlyList<T>). It would be really helpful if you can explain that a bit more. But otherwise, I'll try a bit more.
You can just use an IList<T> and the call .ToList().AsReadOnly()); to convert it to readonly one.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.