简体   繁体   English

Microsoft Bot Framework DirectLine无法访问对话

[英]Microsoft Bot Framework DirectLine Can't Access Conversations

I am trying to use the Microsoft Bot Framework DirectLine API to read and add messages to existing conversations between other users and my bot. 我正在尝试使用Microsoft Bot Framework DirectLine API来读取和添加消息到其他用户和我的机器人之间的现有对话。 From what I've read I believe this should be possible when using the master-secret but it's just not working for me. 从我所读到的内容来看,我相信在使用主秘密时这应该是可能的,但它不适合我。 I'm using a WebAPI to try and access two of my existing conversations (on Facebook & Skype) as follows: 我正在使用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 :-)";
    }

It fails silently calling PostMessage() and fails with a 404 for the GetMessages(). 它无法以静默方式调用PostMessage(),并因GetMessages()而失败。 I seem to be doing the right thing, the bot is live etc and works very well in Facebook & Skype separately from the DirectLine API. 我似乎正在做正确的事情,机器人是现场等,并且在Facebook和Skype中与DirectLine API分开工作。 It only works if I create a new conversation using the DirectLine API, I can then access its messages and post new messages to it. 它只有在我使用DirectLine API创建新会话时才有效,然后我可以访问其消息并向其发布新消息。

This question sort of helps but doesn't quite tell me what to do to fix it: Difficulty accessing messages in an existing conversation in Microsoft Bot Framework 这个问题有点帮助,但并不能告诉我如何解决它: 在Microsoft Bot Framework中访问现有对话中的消息困难

Any help would be much appreciated. 任何帮助将非常感激。

Thanks 谢谢

For security reasons, you can't use DirectLine to spy on messages from another conversation. 出于安全原因,您无法使用DirectLine监视来自其他对话的邮件。 For the scenario you describe (escalating to a human) there a number of different ways to approach this. 对于您描述的场景(升级为人类),有许多不同的方法可以解决这个问题。 One is to have your bot broker conversations between the accounts (ie Facebook End User <-> Your Bot <-> Facebook Support Person). 一种是在账户之间进行机器人经纪人对话(即Facebook最终用户< - >你的机器人< - > Facebook支持人员)。 Each is talking to the bot, and the bot passes the message through to the other user. 每个人都在与机器人交谈,机器人将消息传递给其他用户。 (Could also be Facebook User <-> Your Bot <-> Skype User) Your bot would have to store last n messages to provide context. (也可能是Facebook用户< - >您的机器人< - > Skype用户)您的机器人必须存储最后n条消息以提供上下文。 Alternatively, I've seen folks build their own customer support chat interface using direct line that sits on the far side. 或者,我已经看到人们使用位于远端的直线构建他们自己的客户支持聊天界面。 Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM