【问题标题】:There was an error sending this message to your bot: HTTP status code InternalServerError将此消息发送到您的机器人时出错:HTTP 状态代码 InternalServerError
【发布时间】:2017-06-15 07:57:52
【问题描述】:

我的机器人突然停止工作......

我使用 botframework luis.ai c# 创建了一个机器人。我已经部署在 azure 中。

机器人运行良好,但现在当我向机器人发送消息时收到此代码:向您的机器人发送此消息时出错:HTTP 状态代码 InternalServerError。

我尝试在我的 luis.ai 中生成另一个密钥并添加到我的代码中......但我仍然遇到同样的问题。

P.S 我的 botframework 已更新为最新版本。

MessagesController.cs:

using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;

namespace FirstBotApplication
{
//[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 AllTheBot());
        }
        else
        {
            HandleSystemMessage(activity);
        }
        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)
        {

        }
        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;
      }
     }
    }

AllTheBot.cs

using Microsoft.Bot.Builder.Dialogs;
  using Microsoft.Bot.Builder.Luis;
 using Microsoft.Bot.Builder.Luis.Models;
  using Microsoft.Bot.Connector;
 using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Web;


namespace FirstBotApplication
{
//  [LuisModel("Please Enter Your LUIS Model ID", "Please Enter Your LUIS 
Subscription Key")]

[Serializable]

[LuisModel("xxxxxxxx", 
                        "yyyyyyy")]

public class AllTheBot : LuisDialog<object>
{
    // internal static string results;
    [LuisIntent("None")]
    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        string message = $"Sorry, I did not understand '{result.Query}'. Please reformulate your question";

        await context.PostAsync(message);

        context.Wait(this.MessageReceived);

}


    // private const string HeroCard = "Hero card";




    [LuisIntent("grettings")]
    [LuisIntent("intentfr")]
    public async Task Greeting(IDialogContext context, 
    IAwaitable<IMessageActivity> activity, LuisResult result)
    {


            await context.PostAsync("Welcome  ");

            context.Wait(MessageReceived);

    }`
       }}

【问题讨论】:

  • 你能用有问题的代码更新这篇文章吗?否则很难给出建议......
  • 哪一行产生了错误?
  • 当我在 botframework 模拟器中测试(版本更新)..我无法连接此消息的原因:写 EPROTO 101057795:error:140770FC:SSL 例程:SSL23_GET_SERVER_HELLO:unknown protocol:c:\jenkins\workspace \electron-win-x64\vendor\node\deps\openssl\openssl\ssl\s23_clnt.c:794
  • 将 AppInsights 添加到您的 Bot 并查看记录的异常

标签: c# azure botframework azure-language-understanding


【解决方案1】:

您在此处发布的代码是否与您的代码完全匹配,如果是,您可能需要查看格式错误。

我认为主要问题是你的声明

[LuisIntent("grettings")]
[LuisIntent("intentfr")]
public async Task Greeting(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
    await context.PostAsync("Welcome");

    context.Wait(MessageReceived);
}

根据我的经验,当我有更多错误时,我会遇到错误

IDialogContextLuisResult 作为 LUIS 任务的参数。尝试从您的参数中删除 IAwaitable&lt;IMessageActivity&gt; activity

[LuisIntent("grettings")]
[LuisIntent("intentfr")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
    await context.PostAsync("Welcome");

    context.Wait(MessageReceived);
}

【讨论】:

    【解决方案2】:

    我有同样的问题。我最终重新创建了机器人并重新启动了我的机器。像魅力一样工作

    【讨论】:

      猜你喜欢
      • 2020-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-01
      • 2021-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多