gpt4 book ai didi

c# - 将此消息发送到您的机器人时出错 : HTTP status code InternalServerError

转载 作者:太空宇宙 更新时间:2023-11-03 15:04:12 24 4
gpt4 key购买 nike

我的机器人突然停止运行......

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

该机器人工作得很好,但现在当我向我的机器人发送消息时,我收到此代码:向您的机器人发送此消息时出错:HTTP 状态代码 InternalServerError 。

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

P.S 我的机器人框架已更新为最新版本。

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

}`
}}

最佳答案

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

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

[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<IMessageActivity> activity根据您的参数:

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

context.Wait(MessageReceived);
}

关于c# - 将此消息发送到您的机器人时出错 : HTTP status code InternalServerError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44561850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com