0

我无法将文件附件从机器人发送给 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);
4

1 回答 1

1

除了迫切需要升级您的 botbuilder 版本之外,还有一个示例。请参阅它以获得进一步的指导。它位于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 版本引起的

于 2018-03-06T20:25:41.597 回答