1

我正在尝试替换具有多个 CardAction 按钮的 HeroCard。我想使用 AdaptiveCards,但是,我没有看到任何说明如何从 AdaptiveCard 按钮启用 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
        };
4

2 回答 2

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);
于 2017-05-22T17:14:27.667 回答
0

你试过SubmitAction吗?

var noAction = new CardAction()
{
    Value = "Nope",
    Type = SubmitAction.TYPE,
    Title = "No, I'll try it"
};
于 2017-05-15T23:39:33.383 回答