使用机器人在Skype中无法预期地接收到数据 [英] Data not predictably received in skype using bots

查看:75
本文介绍了使用机器人在Skype中无法预期地接收到数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Microsoft BotFramework 进行 Bots 项目我用来显示一些视频文件.在这里,我面临的问题是,当我在本地Bot Frame工作模拟器中运行项目时,每次都能正确获取数据,并且我将Bot配置为Skype Channel使其第一次正常工作,而第二次使用它时,有时无法获取数据,有时只能获取像一个视频文件之类的数据,而只是第一个视频文件. 是否有适当的解决方案来每次获取完整的数据? 为此,我将下面的代码行写入我的方法

I am working on Bots Project using Microsoft BotFramework, in that I am using to display some video files. Here I am facing the issue is when I am running my project in local Bot Frame work Emulator its getting the data properly at every time and I am configuring my Bot to Skype Channel its working first time properly and when I am using the second time it’s not getting the data some times and sometimes it’s getting data like only one video file that is nothing but first video file. Is there any proper solution for getting the complete data every time? For this I am write the below line of code in my method

Activity replyToConversation = message.CreateReply("Welcome to **My Bot**." + "(Hi)");
        replyToConversation.Recipient = message.From;
        replyToConversation.Type = "message";
        replyToConversation.Attachments = new List<Attachment>();
        Dictionary<string, string> cardContentList = new Dictionary<string, string>();
        cardContentList.Add("Jason Bourne", "");
        cardContentList.Add("The Land", "");
        cardContentList.Add("Yoga Hosers", "");
        foreach (KeyValuePair<string, string> cardContent in cardContentList)
        {
            if (cardContent.Key == "Jason Bourne")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mz35iB6o_EJVzJvmSQz9_jNz5Cmpk33LgbGJQjpoZvQaBXrABBDvHrOS5gdHvqh_MIlJoFBIujrSkhkCGRnApldRbmT6W61NTEyOulUGUZtge9hRyKKvh9BHT-VYV_opRLSMnHt7g3b3IaiTNKcjZqQ/Jason%20Bourne%20Official%20Trailer%20%231%20(2016",
                    Name = "Jason Bourne"
                                      });
            }
            else if (cardContent.Key == "The Land")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mGspCfSmGDdvQjKK_3UcUIdnZRsAC2jRgHesmL61sIV_zc9F9UQQIWkyHE5E4t6r4T56aWKDQSfN-qduP2VJbiH0rYZ4Ce5DLI2U1DKx-4Tv4UB4OL2Egtk_-BWAow0fC4wf7HCC2ypyQ2dIXrs1hsw/The%20Land%20Official%20Trailer%201%20(2016",

                    ContentType = "video/mp4",
                    Name = "The Land"
                });
            }
            else if (cardContent.Key == "Yoga Hosers")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "https://ht39ea-bn1306.files.1drv.com/y3mThBzywEPjMFSh2rdNldHPW1oxtzVTXyrhLrJOp_ACh2YPLQcuw5W-MaSB_5DBJluNXJpvwWBcoWKcQO6Ijx7dWcj2MqHA2uFvvbH6h7mPKsiBhDuC8j5I4_qi-ZsdMuM2G6ztoUtAsdRV0pla-aOGQ/Yoga%20Hosers%20TRAILER%20(2016",

                    ContentType = "video/mp4",
                    Name = "Yoga Hosers"
                });
            }
        }
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;
        await context.PostAsync(replyToConversation);

推荐答案

两个问题.首先,"Jason Bourne"项缺少ContentType字段,因此该帖子被拒绝了.其次,提供的链接似乎无效或公开可用.如果我添加ContentType字段并换出链接,则可以找到它.

Two issues. First, the"Jason Bourne" item is missing the ContentType field so the post is being rejected. Secondly the links provided don't seem to be valid or publicly available. If I add the ContentType field and swap out the links it works find.

 Activity replyToConversation = message.CreateReply("Welcome to **My Bot**." + "(Hi)");
        replyToConversation.Recipient = message.From;
        replyToConversation.Type = "message";
        replyToConversation.Attachments = new List<Attachment>();
        Dictionary<string, string> cardContentList = new Dictionary<string, string>();
        cardContentList.Add("Jason Bourne", "");
        cardContentList.Add("The Land", "");
        cardContentList.Add("Yoga Hosers", "");
        foreach (KeyValuePair<string, string> cardContent in cardContentList)
        {
            if (cardContent.Key == "Jason Bourne")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",
                    ContentType = "video/mp4",  // NEW LINE
                    Name = "Jason Bourne"
                });
            }
            else if (cardContent.Key == "The Land")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",

                    ContentType = "video/mp4",
                    Name = "The Land"
                });
            }
            else if (cardContent.Key == "Yoga Hosers")
            {
                replyToConversation.Attachments.Add(new Attachment()
                {
                    ContentUrl = "http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_1mb.mp4",

                    ContentType = "video/mp4",
                    Name = "Yoga Hosers"
                });
            }
        }
        replyToConversation.AttachmentLayout = AttachmentLayoutTypes.List;

这篇关于使用机器人在Skype中无法预期地接收到数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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