Search code examples
c#botframeworktelegram-botattachment

Microsoft Bot Framework Attachments


I'm coding a Telegram-bot using MS Bot Framework. I want to use Attachments to collect data from user's selection/choice. Would someone kindly help me with the following:

  1. How to put attachments side-by-side(columns & rows), and make them sizeable? Sample please?
  2. Is it possible to write an iteration code to create rows/columns from a list/Dict?

I attempted to code as per this sample:

 var _card = new HeroCard
 {
 Text = "You can upload an image or select one of the following choices",
 Buttons = new List<CardAction>
 {       
     new CardAction(ActionTypes.ImBack, title: "Part1", value: "1"),
     new CardAction(ActionTypes.ImBack, title: "Part2", value: "2"),

     new CardAction(ActionTypes.ImBack, title: "Part3", value: "3"),
     new CardAction(ActionTypes.ImBack, title: "Part4", value: "4"),         
 },
 };
 var _reply = MessageFactory.Attachment(_card.ToAttachment());
 await turnContext.SendActivityAsync(_reply, cancellationToken);

Solution

  • You won't be able to do this with a Hero card. They are pretty basic and not all that flexible. You might be able to design your intended layout with an Adaptive Card, but Telegram doesn't fully support them. It will render, but only as an image.

    https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channels-reference?view=azure-bot-service-4.0#card-support-by-channel