我无法从机器人向Skype中的用户发送文件附件。我正在使用bot builder版本3.5.0。
以下是我的代码。
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity reply = activity.CreateReply("blah");
reply.Attachments = new List();
Attachment attach = new Attachment();
attach.ContentType = "application/pdf";
// I can browse the below URL in browser and access the PDF
attach.ContentUrl = "https://test.azurewebsites.net/Image/Test.pdf";
attach.Name = "Test.pdf";
attach.Content = "Test";
attach.ThumbnailUrl = attach.ContentUrl;
reply.Attachments.Add(attach);
await connector.Conversations.ReplyToActivityAsync(reply);
答案 0 :(得分:1)
除了迫切需要升级您的botbuilder版本之外,还有一个sample。请参阅它以获得进一步的指导。它位于botbuilder-samples仓库。在样本中,他们构建的附件非常类似于你:
private static Attachment GetInternetAttachment()
{
return new Attachment
{
Name = "BotFrameworkOverview.png",
ContentType = "image/png",
ContentUrl = "https://docs.microsoft.com/en-us/bot-framework/media/how-it-works/architecture-resize.png"
};
}
所以这很可能是由您正在使用的非常过时的botbuilder版本引起的