3

Man am I having issue with this. I am trying to create a simple bot with the help of Luis. I have managed to create a bot and host it on azure, I have also created an intent in LUIS and an entity. I have created some utterances and that side is working fine.

I then created by LuisDialog in c#. I had to create Cognitive Services API subscription in Azure and I copied to 2 keys it had generated into my LuisDialog.

My Dialog looks like this:

/// <summary>
/// Entities for the PiiiCK LUIS model.
/// </summary>
public static partial class PiiiCK
{
    public const string DefaultCategory = "none";
    public const string ChooseCategoryIntent = "Choose category";
}

[Serializable]
public class PiiiCKLuisDialog : LuisDialog<object>
{

    /// <summary>
    /// Tries to find the category
    /// </summary>
    /// <param name="result">The Luis result</param>
    /// <param name="alarm"></param>
    /// <returns></returns>
    public string TryFindCategory(LuisResult result)
    {

        // Variable for the title
        EntityRecommendation title;

        // If we find our enenty, return it
        if (result.TryFindEntity(PiiiCK.ChooseCategoryIntent, out title))
            return title.Entity;

        // Default fallback
        return PiiiCK.DefaultCategory;
    }

    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {

        // Create our response
        var response = $"Sorry I did not understand";

        // Post our response back to the user
        await context.PostAsync(response);

        // Execute the message recieved delegate
        context.Wait(MessageReceived);
    }

    [LuisIntent("Choose category")]
    public async Task ChooseCategory(IDialogContext context, LuisResult result)
    {

        // Get our category
        var category = TryFindCategory(result);
                    
        // Create our response
        var response = $"Found our entity: { category }";

        // Post our response back to the user
        await context.PostAsync(response);

        // Execute the message recieved delegate
        context.Wait(MessageReceived);
    }
}

When I run the project and use the Bot emulator to get my responses it always hits none. Even if I write a message exactly the same as the utterance. Now I assume it is because I have confused myself. I believe there is another step after getting the keys from by Cognitive Service account to link it to LUIS endpoint, does anyone know what I am supposed to do next?


Update

I was using the Alarm bot example to create my bot, but it was confusing me (mainly because I have never used Autofac before), so I have switched to the Simple Alarm bot example instead. The changes I need to make was with Global.asax:

protected void Application_Start() => GlobalConfiguration.Configure(WebApiConfig.Register);

And add the LuisModel Data Annotation to the PiiiCKLuisDialog like so:

[Serializable]
[LuisModel("The Luis App Id", "The microsoft cognitive services subscription key")]
public class PiiiCKLuisDialog : LuisDialog<object>

When I run my application, I get no errors and when I use my Microsoft Bot Emulator with the MicrosoftAppId and Secret I can type a message, but it still does the same as before. It always goes to the None Luis Intent and never to the "Choose category" one. It is worth noting that the LuisResult is always null...

Any ideas?

Community
  • 1
  • 1
r3plica
  • 13,017
  • 23
  • 128
  • 290

1 Answers1

1

You don't need to copy two keys.

You need to only use any one of the two keys as the second argument to LuisModel. For the first argument, use the app ID that looks like a GUID and can be found on LUIS.ai.

Update:

1) Here is what you use as the first parameter to [LuisModel("","")] - that's your LUIS app ID:

enter image description here

2) As the second parameter, you use any of the two keys you got from Azure portal or Cognitive Services account. Doesn't matter which of the two.

Finally, you can always test your endpoint and see both input params from your account at luis.ai. Click "Publish", enter anything into "query", then press Enter. You will see the params in the URL.

enter image description here

  • I changed this to use the first key as the luis app id and the second one the use the cognitive services account key, but it does exactly the same thing. It always returns none. – r3plica Nov 14 '16 at 12:32
  • Just to explain a bit more, I have the MicrosoftAppId and Secret in my web.config file. I have now added the LuisModel data attribute (using the luis app id and the subscription key) to the **PiiiCKLuisDialog** and stopped using Autofac to see if that was an issue and I have changed the **Post** method to the one I have put in my edit. – r3plica Nov 14 '16 at 12:35
  • The subscription key in the luis publish url, where does that come from? – r3plica Nov 14 '16 at 13:51
  • r3plica have you trained your model and publish the application? – Ezequiel Jadib Nov 14 '16 at 14:03
  • Yeah, it is working now, I just want to know if there was any need to use cognitive services as the subscription id I have used in the LuisModel is the one that is in the publish url and it works. – r3plica Nov 14 '16 at 14:12
  • 1
    figured it out, there is a place in luis to add your key for the cognitive service. – r3plica Nov 14 '16 at 14:22
  • I had the exact same issue. So what do you mean by "there is a place in luis to add your key for the cognitive service."? Add which key in which site? I already add the bootstrapkey to my app. – zoe Jul 24 '17 at 06:01
  • Add the subscription key (generated from Azure Portal) to the app settings in the luis.ai website. The answer may not be relevant after the redesign of LUIS though. –  Jul 24 '17 at 07:12