带PostBack按钮的AdaptiveCards

时间:2017-05-15 18:07:13

标签: bots botframework adaptive-cards

我正在尝试更换具有多个CardAction按钮的HeroCard。我想使用AdaptiveCards,但是,我没有看到任何说明如何从AdaptiveCard按钮启用postBack的文档。我看到打开浏览器,什么不是,但没有postBack。

这支持了吗?

        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 个答案:

答案 0 :(得分:0)

您是否尝试过SubmitAction

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

答案 1 :(得分:0)

此代码正确呈现,甚至似乎将信息发送回机器人。但仍然无法弄清楚如何在恢复功能上读回数据:

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);