Botframework 不能';t发送重试,但消息已发送

Botframework 不能';t发送重试,但消息已发送,botframework,Botframework,在bot web聊天中,当我键入消息时,bot会先显示“正在发送”,然后更改为“无法发送,请重试”。但是消息已经发送了,我正在得到回复。我怎样才能避免这种情况?我需要增加消息超时吗?如果是,我需要在哪里设置它 这是代码片段。我使用的是C#SDK,我已经在MessageReceivedASync方法中进行了编码 namespace Bot_Application1.Dialogs { public class HRBotDialog : IDialog<object>

在bot web聊天中,当我键入消息时,bot会先显示“正在发送”,然后更改为“无法发送,请重试”。但是消息已经发送了,我正在得到回复。我怎样才能避免这种情况?我需要增加消息超时吗?如果是,我需要在哪里设置它

这是代码片段。我使用的是C#SDK,我已经在MessageReceivedASync方法中进行了编码

namespace Bot_Application1.Dialogs
{
    public class HRBotDialog : IDialog<object>
    {
        public static string dialogcontext = "";
        public async Task StartAsync(IDialogContext context)
        {
            context.Wait(MessageReceivedAsync);
        }

        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            // Get the text passed
            var message = await argument;
            string typedText = message.Text.ToLower();
            string answer = "My Answer";
            if ((typedText == "hi") || (typedText == "hello"))
            {
                answer = message.Text;

            }
            else if ((typedText == "how many personal days do i have left") || (typedText.Contains("personal days")))
            {
                answer = "Looks like you have 2 remaining for this year";
            }
namespace Bot\u应用程序1.Dialogs
{
公共类对话框:IDialog
{
公共静态字符串dialogcontext=“”;
公共异步任务StartAsync(IDialogContext上下文)
{
Wait(MessageReceivedAsync);
}
专用异步任务消息ReceivedAsync(IDialogContext上下文,IAwaitable参数)
{
//让文本通过
var message=等待参数;
string typedText=message.Text.ToLower();
string-answer=“我的答案”;
if((typedText==“hi”)| |(typedText==“hello”))
{
答案=消息。文本;
}
else if((typedText==“我还剩多少个人工作日”)| |(typedText.Contains(“个人工作日”))
{
回答=“看来你今年还有两个”;
}
我在这里添加控制器代码

//[BotAuthentication]
public class MessagesController : ApiController
{
    /// <summary>
    /// POST: api/Messages
    /// Receive a message from a user and reply to it
    /// </summary>
    public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
    {
        if (activity.Type == ActivityTypes.Message)
        {
            await Conversation.SendAsync(activity, () => new HRBotDialog());
        }
        else
        {
            ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
            var reply = HandleSystemMessage(activity);
            if (reply != null)
                await connector.Conversations.ReplyToActivityAsync(reply);
        }
        var response = Request.CreateResponse(HttpStatusCode.OK);
        return response;
    }

    private Activity HandleSystemMessage(Activity message)
    {

        if (message.Type == ActivityTypes.DeleteUserData)
        {
            // Implement user deletion here
            // If we handle user deletion, return a real message
        }
        else if (message.Type == ActivityTypes.ConversationUpdate)
        {
            string replyMessage = string.Empty;
            if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id))
            {
                replyMessage += $"How can I help you? \n";
                return message.CreateReply(replyMessage);
            }
        }
        else if (message.Type == ActivityTypes.ContactRelationUpdate)
        {
            // Handle add/remove from contact lists
            // Activity.From + Activity.Action represent what happened
        }
        else if (message.Type == ActivityTypes.Typing)
        {
            // Handle knowing tha the user is typing
        }
        else if (message.Type == ActivityTypes.Ping)
        {
        }

        return null;
    }
}
/[BotAuthentication]
公共类消息控制器:ApiController
{
/// 
///帖子:api/Messages
///接收来自用户的消息并回复
/// 
公共异步任务发布([FromBody]活动)
{
if(activity.Type==ActivityTypes.Message)
{
wait Conversation.sendaync(活动,()=>new HRBotDialog());
}
其他的
{
ConnectorClient连接器=新的ConnectorClient(新Uri(activity.ServiceUrl));
var reply=HandleSystemMessage(活动);
如果(回复!=null)
等待连接器.Conversations.ReplyToActivityAsync(reply);
}
var response=Request.CreateResponse(HttpStatusCode.OK);
返回响应;
}
私有活动HandleSystemMessage(活动消息)
{
if(message.Type==ActivityTypes.DeleteUserData)
{
//在此处执行用户删除
//如果我们处理用户删除,返回一条真实的消息
}
else if(message.Type==ActivityTypes.ConversationUpdate)
{
string replyMessage=string.Empty;
if(message.MembersAdded.Any(o=>o.Id==message.Recipient.Id))
{
replyMessage+=$“我能为您做些什么?\n”;
返回message.CreateReply(replyMessage);
}
}
else if(message.Type==ActivityTypes.ContactRelationUpdate)
{
//处理联系人列表中的添加/删除
//Activity.From+Activity.Action表示发生了什么
}
else if(message.Type==ActivityTypes.Typing)
{
//处理知道用户正在键入的内容
}
else if(message.Type==ActivityTypes.Ping)
{
}
返回null;
}
}

请尝试将可序列化属性添加到HRBOT对话框,如下所示:

[Serializable]
public class HRBotDialog : IDialog<object>
{
//...code...
}
[可序列化]
公共类对话框:IDialog
{
//…代码。。。
}

请尝试将可序列化属性添加到HRBOT对话框,如下所示:

[Serializable]
public class HRBotDialog : IDialog<object>
{
//...code...
}
[可序列化]
公共类对话框:IDialog
{
//…代码。。。
}

这是否一致?您是如何创建bot的?(bot服务、节点或C#sdk)?您可以从“Post”中添加代码吗-方法。我在发送空答复时看到了这个问题。按照Xeno-D的建议,请在消息控制器中提供代码。您好,我添加了控制器代码。除了ConversationUpdate消息,所有其他代码都是自动的。嘿,我面临着完全相同的问题,我想知道是否有人有任何建议?这是否一致?您是如何创建bot的?(bot服务、节点或C#sdk)?您可以从“Post”中添加代码吗-方法。我在发送空答复时看到了这个问题。按照Xeno-D的建议,请在消息控制器中提供代码。您好,我添加了控制器代码。除了ConversationUpdate消息,所有其他代码都是自动的。嘿,我面临着完全相同的问题,我想知道是否有人有任何建议?即使将该属性添加到类中,我仍然面临相同的问题。当ResumeAfter方法中调用的对话框执行时,我在模拟器中看到此错误。是否有任何方法可以告诉框架代码正确接收消息?即使将该属性添加到类中,我也会我仍然面临同样的问题。当ResumeAfter方法中调用的对话框执行时,我在emulator中看到这个错误。有没有办法告诉框架代码正确接收到消息?