【发布时间】: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