简体   繁体   中英

Bot Framework C# Luis Getting > Exception: Response status code does not indicate success: 400 (Bad Request)

I need assistance with integrating my Luis App into C# Bot Framework Bot

When I add Luis App to my C# Microsoft Bot Framework chatbot and run in the emulator I get an exception.

Exception: Response status code does not indicate success: 400 (Bad Request).

A debugging post from another developer on Github suggested adding domain, which I have to my LuisModel (see below). This did not resolve the issue.

[LuisModel("", "", domain: "australiaeast.api.cognitive.microsoft.com", Staging = true)]

Stepping through the code, my locals seem correct when it calls the new Dialog.RootLuisDialog() Here is a screen grab

在此处输入图片说明

Message Controller Code Snippet

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 Dialog Class

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);
           }
        }
}
  1. Ran fiddler, encrypted 400 (Bad Request) which stated Model not published. Please publish your model before hitting the endpoint
  2. Republished MyLuisApp
  3. Removed staging from LuisModel [LuisModel("<MyLuisAppID>", "<MyLuisKey>", domain: "australiaeast.api.cognitive.microsoft.com")]

Now Luis integration is working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM