Microsoft Bot Framework messages with buttons in Facebook Messenger

前端 未结 2 1845
南方客
南方客 2020-12-15 13:45

I\'m working on a bot using the C# Microsoft Bot Framework and I\'d like to send messages with action buttons to Facebook Messenger. I\'ve successfully created the bot, depl

2条回答
  •  盖世英雄少女心
    2020-12-15 14:11

    Updating solution for version 3.9.0 :

            var actions = new List();
            for (int i = 0; i < 3; i++)
            {
                actions.Add(new CardAction
                {
                    Title = $"Button:{i}",
                    Text = $"Action:{i}"
                });
            }
    
            reply.Attachments.Add(
                new HeroCard
                {
                    Title = "Choose option",
                    Buttons = actions
                }.ToAttachment()
            );
    
            await context.PostAsync(reply);
    

提交回复
热议问题