Microsoft Bot Framework Messages with Buttons in Facebook Messenger

I am working on a bot using the C # Microsoft Bot Framework, and I would like to send messages using the action buttons in Facebook Messenger. I have successfully created the bot, deployed it and can communicate with it through Messenger, and now I'm trying to clarify the appearance of the bot's answers. I was able to create single cards and carousels by putting the card information in Message.Attachements, but I would also like to include action buttons. The Messenger Platform describes the buttons and β€œcommon” templates in the Send API Reference , but for life I can’t figure out how to get the Bot Connector to send Messenger buttons. It would be great if I could just put the Send json API in the Message.ChannelData property, but no luck. Has anyone been able to get Messenger to show buttons from the Bot Framework?

+4
source share
3 answers

To add buttons to a message, you can add several actions to the application. Each action will be displayed on a button using a connector. Several attachments will be displayed in the carousel in the Facebook messenger. The following is an example of adding 3 messages to a 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); 
+7
source

Update for version 3.9.0:

  var actions = new List<CardAction>(); 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); 
+1
source

MESSAGE AUTOMATION: UNE REPONSE NE DEVRAIT PAS TARDER A ARRIVAL! Good afternoon, welcome message, good essay and feedback, as well as difficult times!

Signature: Mathieu Roberger

0
source

All Articles