To add buttons to your message, you can add multiple actions to the attachment. Each action will be mapped to a button by connector. Multiple attachments will be mapped into a carousel in Facebook messenger. Below is an example of adding 3 buttons to the message.
var reply = context.MakeMessage();
reply.Attachments = new List<Attachment>();
var actions = new List<Microsoft.Bot.Connector.Action>();
for (int i = 0; i < 3; i++)
{
actions.Add(new Microsoft.Bot.Connector.Action
{
Title = $"Button:{i}",
Message = $"Action:{i}"
});
}
reply.Attachments.Add(new Attachment
{
Title = "Choose one:",
Actions = actions
});
await context.PostAsync(reply);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…