0

I am trying to add a custom data payload to PromptDialog.Choice / or PromptDialog.Text to indicate a special activity to my bot client.

I know there is a field to specify InputHint to IMessageActivity. is there a way to add an inputhint/ or a custom tag to PromptDialog flow?

zingh
  • 404
  • 4
  • 11

1 Answers1

0

Your best bet is to use something like this:

var options = new PromptOptions()
{
    Prompt = MessageFactory.Text("Pick Me!"),
    Choices = new List<Choice>()
};
var channelData = new Dictionary<string, string>();
channelData["testKey"] = "testValue";
options.Choices.Add(new Choice()
{
    // Value must be set. There's a PR in place to fix this, but for now just leave blank
    Value = "",
    Action = new CardAction()
    {
        // PostBack will prevent the user from seeing "Actual Value" after they select it
        Type = ActionTypes.PostBack,
        Title = "DISPLAYED TEXT",
        Value = "ACTUAL VALUE",
    }
});
return await stepContext.PromptAsync(nameof(ChoicePrompt), options);

The comments I left in the code should be explanatory enough.

Another solution might be to display a set of cards that include the ChannelData, then a blank text prompt to wait for the user's response. I have a pretty in-depth answer for how to do this. You'd just need to add a ChannelData property so that you can capture your "special activity" code.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21
  • i don't see channelData object being used in your code snippet – zingh May 02 '19 at 04:16
  • When creating the `Activity`, you add the cards to `Activity.attachments`. `Activity` also holds `ChannelData`, so while constructing your `Activity`, use something like `ChannelData = new { SpecialKey = SpecialValue }` – mdrichardson May 02 '19 at 14:53