簡體   English   中英

Microsoft Bot框架和附件

[英]Microsoft Bot Framework and attachments

我有一個運行正常的機器人,但是當我嘗試包含附件時,出現“內部服務器錯誤”,這是我做錯了什么? 我使用Microsoft Bot Framework示例。

Attachment attachment = new Attachment();
attachment.ContentType = "image/png";
attachment.ContentUrl = "http://www.southsystem.net/ss3blue3d.jpg";
Activity reply = activity.CreateReply("test");
reply.Attachments.Add(attachment); // need to comment to work
await connector.Conversations.ReplyToActivityAsync(reply);

如果我對Attachments.Add評論,則效果很好,沒有錯誤。 我已經處理了好幾天,並嘗試了一切。 任何幫助,非常感謝。

您需要在添加Attachments之前初始化Attachments列表。

reply.Attachments = new List<Attachment>();
reply.Attachments.Add(attachment);

根據先前的答案:

如果您想在沒有附件列表的情況下進行回復,則必須創建以下內容:

var msg = context.MakeMessage();
msg.Text = "some text for your attachment";
msg.Attachments.Add(att);
await context.PostAsync(msg);

您必須在回復郵件中添加一些文字。 否則,它不會出現任何錯誤,但不會顯示該消息。 我以這種方式進行測試,並且可以正常工作。 希望這個能對您有所幫助 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM