Microsoft Bot Framework DirectLine无法访问对话 [英] Microsoft Bot Framework DirectLine Can't Access Conversations

查看:141
本文介绍了Microsoft Bot Framework DirectLine无法访问对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Microsoft Bot Framework DirectLine API读取消息并将消息添加到其他用户与我的机器人之间的现有对话中.根据我的阅读,我相信使用主密钥时应该可以实现,但是对我来说不起作用.我正在使用WebAPI尝试访问我现有的两个对话(在Facebook和Skype上),如下所示:

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. 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:

    [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()失败,并以Get404s()的404失败.我似乎做对了,该机器人已经上线,并且在Facebook& amp;上运行得很好. Skype与DirectLine API分开.仅当我使用DirectLine API创建新对话时,它才起作用,然后我可以访问其消息并向其发布新消息.

It fails silently calling PostMessage() and fails with a 404 for the 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. 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.

这个问题有点帮助,但并没有告诉我如何解决它: 在Microsoft Bot中现有对话中访问消息很困难框架

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

任何帮助将不胜感激.

谢谢

推荐答案

出于安全原因,您不能使用DirectLine监视来自另一个对话的消息.对于您描述的场景(逐步升级为人类),有多种方法可以解决此问题.一种是让您的机器人经纪人在帐户之间进行对话(即Facebook最终用户<->您的Bot<-> Facebook支持人员).每个人都在与机器人聊天,然后机器人将消息传递给另一个用户. (也可以是Facebook用户<->您的Bot<-> Skype用户).您的机器人必须存储最后n条消息才能提供上下文.另外,我已经看到人们使用位于远端的直线构建自己的客户支持聊天界面.希望这会有所帮助

For security reasons, you can't use DirectLine to spy on messages from another conversation. 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 (i.e. Facebook End User <-> Your Bot <-> Facebook Support Person). 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. Alternatively, I've seen folks build their own customer support chat interface using direct line that sits on the far side. Hope this helps

这篇关于Microsoft Bot Framework DirectLine无法访问对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆