我正在尝试使用 Microsoft Bot Framework DirectLine API 来读取消息并将消息添加到其他用户和我的机器人之间的现有对话中。从我读过的内容来看,我相信在使用主机密时这应该是可能的,但它对我不起作用。我正在使用 WebAPI 尝试访问我现有的两个对话(在 Facebook 和 Skype 上),如下所示:
[HttpPost]
[Route("remind")]
public string Remind()
{
var secret = System.Configuration.ConfigurationManager.AppSettings["secret"];
var uri = new Uri("https://directline.botframework.com/");
var creds = new DirectLineClientCredentials(secret);
DirectLineClient client = new DirectLineClient(uri, creds);
Conversations convs = new Conversations(client);
var conversationIDs = new string[] { "0000000000000000-0000000000000000", "00:0123456789abcdefghijklmnopqrstuvwxyz0123456789-A-_0123456798ABCDEF" }; // Existing Facebook & Skype conversations
// Send a message to each conversation:
foreach (var conversationID in conversationIDs)
{
Message message = new Message(conversationId: conversationID, fromProperty: "My Bot", text: "Hey dude, remember that thing!");
Console.WriteLine(message.Text);
convs.PostMessage(conversationID, message); // FAILS - This executes but doesn't do anything.
}
// Try reading the messages from a conversation (just to test if it's working):
string waterMark = null;
var set = convs.GetMessages(conversationIDs[0], waterMark); // FAILS - This fails with a 404 not found.
waterMark = set.Watermark;
return "Done :-)";
}
它以静默方式调用 PostMessage() 失败,并为 GetMessages() 失败并返回 404。我似乎在做正确的事情,该机器人是实时的,并且在 Facebook 和 Skype 中与 DirectLine API 分开运行良好。它仅在我使用 DirectLine API 创建新对话时才有效,然后我可以访问其消息并向其发布新消息。
这个问题有点帮助,但并不能完全告诉我如何解决它: Difficulty access messages in an existing conversation in Microsoft Bot Framework
任何帮助将非常感激。
谢谢