使用ms bot从byte []发送图像,频道:Facebook,C#

时间:2020-04-18 11:52:19

标签: c# facebook botframework chatbot facebook-chatbot

我需要在漫游器中发送图像。将我的图像转换为字节数组。

在模拟器中图像正在发送,但是在Facebook中,它没有发送。

下面是我的代码。

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);

我见过

当图像转换为字节时,太长而无法作为ContentUrl发送,这就是为什么它失败了。 任何帮助表示赞赏。

谢谢

1 个答案:

答案 0 :(得分:0)

当使用太大的图像作为数据URL进行嵌入时,您需要在服务器上提供指向该图像的链接