1
votes

I am trying to replace a HeroCard that has multiple CardAction buttons. I would like to use AdaptiveCards, however, I don't see any documentation that states how to enable postBack from an AdaptiveCard button. I see open browser, and what not, but no postBack.

Is this supported yet?

        var cardButtons = new List<CardAction>();
        var yesAction = new CardAction()
        {
            Value = "Yes",
            Type = "postBack",
            Title = "Yes"
        };
        cardButtons.Add(yesAction);

        var noAction = new CardAction()
        {
            Value = "Nope",
            Type = "postBack",
            Title = "No, I'll try it"
        };
        cardButtons.Add(noAction);

        var plCard = new HeroCard()
        {
            Title = $"Are you sure?",
            Buttons = cardButtons
        };
2
Action.Http opens a url, my buttons don't, they are shortcuts back to the bot service.NiteLordz

2 Answers

0
votes

Have you tried SubmitAction?

var noAction = new CardAction()
{
    Value = "Nope",
    Type = SubmitAction.TYPE,
    Title = "No, I'll try it"
};
0
votes

This code renders correctly, even seems to send information back to the bot. But still cannot figure out how to read the data back on the resuming function:

var card = new AdaptiveCard();
card.Body.Add(
    new ColumnSet() {
        Columns = new List<Column>() {
            new Column() {
                SelectAction = new SubmitAction() { Data = 3, Title = "Good" },
                Items = new List<CardElement>() { new Image() { Url = GeneralStrings.Feedback03 } }
            },
            new Column() {
                SelectAction = new SubmitAction() { Data = 2, Title = "Average" },
                Items = new List<CardElement>() { new Image() { Url = GeneralStrings.Feedback02 } }
            },
            new Column() {
                SelectAction = new SubmitAction() { Data = 1, Title = "Bad" },
                Items = new List<CardElement>() { new Image() { Url = GeneralStrings.Feedback01 } }
            }
        }
    });

var attachemnt = new Attachment() { ContentType = AdaptiveCard.ContentType, Content = card };

var message = context.MakeMessage();
message.Attachments.Add(attachemnt);

await context.PostAsync(message);
context.Wait<Activity>(this.AfterAskFeedback);