0
votes

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

enter image description here

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
HTTP error 400 means the server tells you it doesn't like what you sent (or doesn't understand it). You can use a tool such as fiddler to check if it sent additional info in the HTTP response body so you can fix your code.Simon Mourier
Thanks @SimonMourier, Fiddler shows Model not published. Please publish your model before hitting the Endpoint. I have published the Luis App and just went back and republished. Any other ideas?Adam
If it keeps telling you your model is published, nope, beside checking you published the proper model :-)Simon Mourier

1 Answers

0
votes
  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.