Bots Directline间歇性地不给出响应或给出回音响应

Bots Directline间歇性地不给出响应或给出回音响应,bots,botframework,direct-line-botframework,Bots,Botframework,Direct Line Botframework,我有一个通过directline调用机器人的代码。directline间歇性地停止给出响应或开始给出与输出相同的输入问题。我只得到一个消息数组,它只包含相同的输入请求消息,没有来自bot的响应。我已经附加了调试期间得到的bot响应。有人对此有任何线索吗 using DirectLineConsole; using DirectLineConsole.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Syst

我有一个通过directline调用机器人的代码。directline间歇性地停止给出响应或开始给出与输出相同的输入问题。我只得到一个消息数组,它只包含相同的输入请求消息,没有来自bot的响应。我已经附加了调试期间得到的bot响应。有人对此有任何线索吗

    using DirectLineConsole;
using DirectLineConsole.Models;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace DirectLineConsole
{
    class RequestOrchestrator
    {
        Conversation objconversation = new Conversation();

        public static string secret_key = "BotConnector abc";

        public static string Service_URL = "https://directline.botframework.com/api/conversations/";

        static void Main(string[] args)
        {

            RequestOrchestrator objprogram = new RequestOrchestrator();

            var task = objprogram.PostMessage("how can i change my phone number?").GetAwaiter().GetResult();

                Console.WriteLine("The get static message is " + objprogram.PostMessage("Its 93091").GetAwaiter().GetResult());
            Console.ReadKey();
            Console.ReadLine();


        }


        private async Task<bool> PostMessage(string message)
        {

            bool IsReplyReceived = false;

            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://directline.botframework.com/api/conversations/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

             client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BotConnector", "abc");
            HttpResponseMessage response = await client.GetAsync("/api/tokens/");
            if (response.IsSuccessStatusCode)
            {
                var conversation = new Conversation();
                response = await client.PostAsJsonAsync("/api/conversations/", conversation);
                if (response.IsSuccessStatusCode)
                {
                    CathyDirectConversation ConversationInfo = response.Content.ReadAsAsync(typeof(CathyDirectConversation)).Result as CathyDirectConversation;
                        string conversationUrl = ConversationInfo.conversationID + "/messages/";

                    MessageNew msg = new MessageNew() { text = message };
                    response = await client.PostAsJsonAsync(conversationUrl, msg);
                    if (response.IsSuccessStatusCode)
                    {
                        response = await client.GetAsync(conversationUrl);
                        if (response.IsSuccessStatusCode)
                        {
                            MessageSetNew BotMessage = response.Content.ReadAsAsync(typeof(MessageSetNew)).Result as MessageSetNew;
                            foreach (Message responseMessage in BotMessage.messages)
                            {

                                Console.WriteLine("The response text " + responseMessage.text);


                            }
                            IsReplyReceived = true;
                        }
                    }
                }

            }
            return IsReplyReceived;

        }

使用DirectLineConsole;
使用DirectLineConsole.Models;
使用Newtonsoft.Json;
使用Newtonsoft.Json.Linq;
使用制度;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
Net系统;
使用System.Net.Http;
使用System.Net.Http.Header;
使用系统文本;
使用System.Threading.Tasks;
使用System.Web;
命名空间DirectLineConsole
{
类请求编排器
{
Conversation objconversation=新对话();
公共静态字符串secret\u key=“BotConnector abc”;
公共静态字符串服务\u URL=”https://directline.botframework.com/api/conversations/";
静态void Main(字符串[]参数)
{
RequestOrchestrator objprogram=新的RequestOrchestrator();
var task=objprogram.PostMessage(“如何更改电话号码?”).GetAwaiter().GetResult();
WriteLine(“获取静态消息是”+objprogram.PostMessage(“其93091”).GetAwaiter().GetResult());
Console.ReadKey();
Console.ReadLine();
}
专用异步任务后消息(字符串消息)
{
bool IsReplyReceived=false;
HttpClient=新的HttpClient();
client.BaseAddress=新Uri(“https://directline.botframework.com/api/conversations/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
client.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“BotConnector”、“abc”);
HttpResponseMessage response=wait client.GetAsync(“/api/tokens/”);
if(响应。IsSuccessStatusCode)
{
var conversation=newconversation();
response=wait client.PostAsJsonAsync(“/api/conversations/”,conversation);
if(响应。IsSuccessStatusCode)
{
CathyDirectConversation ConversationInfo=response.Content.ReadAsAsync(typeof(CathyDirectConversation))。结果为CathyDirectConversation;
字符串conversationUrl=ConversationInfo.conversationID+“/messages/”;
MessageNew msg=newmessagenew(){text=message};
response=wait client.postsjsonasync(conversationUrl,msg);
if(响应。IsSuccessStatusCode)
{
response=wait client.GetAsync(conversationUrl);
if(响应。IsSuccessStatusCode)
{
MessageSetNew BotMessage=response.Content.ReadAsAsync(typeof(MessageSetNew))。结果为MessageSetNew;
foreach(BotMessage.messages中的消息响应消息)
{
Console.WriteLine(“响应文本”+响应消息.text);
}
IsReplyReceived=真;
}
}
}
}
已收到退货;
}

所以……如果不看到您的代码,就很难知道发生了什么。您是否正在做与展示内容类似的事情@?谢谢Ezequiel的回复。我已经添加了代码。如果您能看一下并回复,我将不胜感激。您有什么理由不使用DirectLine Nuget软件包吗?因此……这将是一个好消息如果没有看到您的代码,就很难知道发生了什么。您是否正在执行与展示的@类似的操作?感谢Ezequiel的响应。我已经添加了代码。如果您能查看一下并回复,我将不胜感激。您为什么不使用DirectLine Nuget包?