Search code examples
c#facebookbotframeworkchatbotfacebook-chatbot

Send Image from byte[] using ms bot, Channel: Facebook, C#


I need to send image in bot. converted my Image to Byte Array.

In emulator image is sending, but in Facebook, it is not sending.

Below is my code.

byte[] imageBytes12 = my image;
string url = "data:image/png;base64," + Convert.ToBase64String(imageBytes12);

var attachmentsImage = new List<Attachment>();
var replyImage = MessageFactory.Attachment(attachmentsImage);
HeroCard menuCardImage = Cards.HeroImageCard(url);
replyImage.Attachments.Add(menuCardImage.ToAttachment());
await stepContext.Context.SendActivityAsync(replyImage, cancellationToken);

I have seen

when image is converted as byte, it is too lengthy to send as ContentUrl, thats why it is failing. Any help is appreciated.

Thanks


Solution

  • When using an image that's too large to embed as a data URL, you will need to provide a link to the image on a server