【发布时间】:2018-09-12 06:21:12
【问题描述】:
我需要帮助将我的 Luis 应用程序集成到 C# Bot Framework Bot 中
当我将 Luis App 添加到我的 C# Microsoft Bot Framework 聊天机器人并在模拟器中运行时,我遇到了异常。
异常:响应状态码不表示成功:400(错误请求)。
Github 上另一位开发人员的调试帖子建议添加域,我必须将其添加到我的 LuisModel(见下文)。这并没有解决问题。
[LuisModel("", "", 域:“australiaeast.api.cognitive.microsoft.com”,Staging = true)]
单步执行代码,我的本地人在调用 new Dialog.RootLuisDialog() 时似乎是正确的这是屏幕截图
消息控制器代码片段
public async Task<HttpResponseMessage> Post([FromBody] Activity activity)
{
// check if activity is of type message
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new Dialogs.RootLuisDialog());
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
Luis 对话框类
namespace HalChatBot.Dialogs
{
[LuisModel("<MyLuisAppID>", "<MyLuisKey>",
domain: "australiaeast.api.cognitive.microsoft.com", Staging = true)]
[Serializable]
public class RootLuisDialog : LuisDialog<object>
{
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Default intent");
context.Wait(MessageReceived);
}
[LuisIntent("Greeting")]
public async Task Greeting(IDialogContext context, LuisResult result)
{
await context.PostAsync("I am the Greeting intent");
context.Wait(MessageReceived);
}
}
}
【问题讨论】:
-
HTTP 错误 400 表示服务器告诉您它不喜欢您发送的内容(或不理解)。您可以使用 fiddler 之类的工具来检查它是否在 HTTP 响应正文中发送了其他信息,以便您修复代码。
-
感谢@SimonMourier,Fiddler 显示模型未发布。请在到达端点之前发布您的模型。我已经发布了 Luis 应用程序,然后返回并重新发布。还有其他想法吗?
-
如果它一直告诉你你的模型已经发布,不,除了检查你发布了正确的模型:-)
标签: c# botframework azure-language-understanding