1

I am working with bot framework adaptive dialog. I have an issue in getting the intents and resolved entities by reading luis data using recognizer. only getting the top scoring intent in the response by reading "turn.recognized" in the child adaptive dialog.i have migrated my luis to v3 and set the IncludeAllIntents property to true while calling the luis. did i miss to set any property in the LuisAdaptiveRecognizer.? Could anyone help me to resolve this because i have a scenario to check the second top scoring intent in bot. Is this an issue with adaptive dialog?

I have used Ms docs to build the bot adaptive dialog.

And one more thing Is there any way to extract the luis resolved entities as a type of RecognizerResult from the result of turn.recognized.

Root dialog:

var rootDialog = new AdaptiveDialog(nameof(AdaptiveDialog))
{
    Recognizer = new LuisAdaptiveRecognizer()
    {
        ApplicationId = Configuration["LuisAppId"],
        EndpointKey = Configuration["LuisAPIKey"],
        Endpoint = Configuration["LuisAPIHostName"],
        PredictionOptions = new Microsoft.Bot.Builder.AI.LuisV3.LuisPredictionOptions
        {
            IncludeAllIntents = true,
            IncludeInstanceData = true,
            IncludeAPIResults = true,
            PreferExternalEntities = true,
            Slot = "producton"
        }
    },
    Triggers = new List<OnCondition>()
    {
         new OnIntent("Greetings")
        {
            Actions = new List<Dialog>()
            {
                new SendActivity("${HelpRootDialog()}")
            }
        },
    },

Child dialog:

public FindLinks(IConfiguration configuration) : base(nameof(FindLinks))
{
    _configuration = configuration;
    this.LinksDialog = new AdaptiveDialog(nameof(FindLinks))
    {
        Triggers = new List<OnCondition>()
        {
            new OnBeginDialog()
            {
                Actions = new List<Dialog>()
                    {
                        new CodeAction(ResolveAndSendAnswer)
                    }
            },
        }
    };

    AddDialog(this._findLinksDialog);
    InitialDialogId = nameof(FindLinks);
}

private async Task<DialogTurnResult> ResolveAndSendAnswer(DialogContext dialogContext, System.Object options)
{
    JObject jObject;
    IList<string> queries = new List<string>();
    dialogContext.State.TryGetValue("turn.recognized", out jObject);

    ....This is how i resolved the luis data from the turn.
}
Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66
Mahesh cm
  • 77
  • 1
  • 2
  • 9
  • Welcome to Stack Overflow. Can you provide a code sample and links to the documents you followed to help us reproduce your issue? Please have a look at the handy guide to see the steps you can take to get a better answer faster: https://stackoverflow.com/help/how-to-ask – Kyle Delaney Jul 16 '20 at 19:14
  • Thanks for your reply... I have uploaded sample code files in below drive location. Please check @KyleDelaney [link](https://drive.google.com/drive/folders/1CMv3tb0iD8gMb2klndiEZ0YGlT14MH8Q?usp=sharing) Thanks in advance – Mahesh cm Jul 17 '20 at 07:04
  • You said "I have used Ms docs to build the bot adaptive dialog." Can you link to the docs you're talking about? – Kyle Delaney Jul 17 '20 at 20:23
  • @KyleDelaney I have shared the sample code in that drive link. below are the links which i used. [MS bot samples link](https://github.com/microsoft/BotBuilder-Samples) and [Adaptive dialog](https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-adaptive-dialog-Introduction?view=azure-bot-service-4.0) – Mahesh cm Jul 20 '20 at 05:03
  • When I test your code, I get a 400 error. Have you fixed the typo from "producton" to "production"? – Kyle Delaney Jul 20 '20 at 21:50
  • @KyleDelaney I have done that, but there is no change in the luis data. – Mahesh cm Jul 27 '20 at 08:29
  • Is my answer acceptable? – Kyle Delaney Jul 29 '20 at 22:43
  • @KyleDelaney, Thank you for the solution . I am checking the possibilities. – Mahesh cm Aug 03 '20 at 10:19

1 Answers1

1

Unfortunately, adaptive dialogs are designed to only include one intent in turn.recognized regardless of what kind of recognizer you use. You can see that in the source code here:

result.Intents.Clear();
result.Intents.Add(topIntent, topScore);

It looks like the only place the other intents can be accessed is in your telemetry. So you have a few options, though I know they're not ideal.

  1. Call your LUIS endpoint explicitly instead of relying on LuisAdaptiveRecognizer. This could be done using an HTTP request as an action inside your adaptive dialog, or it could be done outside the dialog.
  2. Load the extra intents from the logged telemetry. This would perhaps be easiest if you made a custom telemetry client that made the data available in your bot's local memory.
  3. Make a feature request on GitHub, asking them to make all intents available in adaptive dialogs: https://github.com/microsoft/botbuilder-dotnet/issues/new/choose
Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66
  • Hi Kyle Delaney, i have done the changes in the adaptive dialog. I have one more doubt , is there any way to extract the luisadaptiverecognizer result to a type like RecognizerResult in the child dialogs? I am stuck on extracting the luis data in child dialogs. Please help me if you have any idea on this. – Mahesh cm Aug 18 '20 at 13:42
  • I think I've already answered that if you read my answer. "Call your LUIS endpoint explicitly instead of relying on LuisAdaptiveRecognizer." – Kyle Delaney Aug 18 '20 at 17:19
  • I have done that, i want to know is there any way to extract the luis endpoint result data to RecognizerResult type in the child dialogs – Mahesh cm Aug 19 '20 at 04:30
  • You can probably do that with Newtonsoft. Have a look at the adaptive dialogs source code if you need an example. – Kyle Delaney Aug 19 '20 at 17:59
  • I have already tried to cast the luis result to recognizerResult type, but it throwing an error. below given the code which i have used. //Extract luis data in child dialogs. var jObject; dialogContext.State.TryGetValue("turn.recognized", out jObject); var recognizer = (RecognizerResult)jObject; – Mahesh cm Aug 20 '20 at 04:59
  • That code can't compile because you're using var without initializing the variable, so clearly that's not your actual code. But you shouldn't be posting multi-line code in comments anyway. If you've made an actual effort to learn how to convert JSON to C# types and you still can't figure out how to do it then you should ask a new question that includes the research you've done and the attempts you've made. – Kyle Delaney Aug 20 '20 at 17:45
  • I can able get the luis data in JObject variable, i have the issues with casting the jobject to RecognizerResult type. I think normal Json convert can't apply for this case. I am looking for another solution. – Mahesh cm Aug 21 '20 at 05:42
  • 1
    I've asked you to look at the source code. I've asked you to look up how to convert JObjects to C# types. I've asked you to post a new question. You're unwilling to do anything at all to help yourself, and you expect me to keep doing work for you. If you won't do any work then solving this problem must not be that important to you, so why are you still commenting? To be honest, I did search "jobject to object" for you and came across an answer that might point you in the right direction: https://stackoverflow.com/questions/4441466/how-to-deserialize-a-jobject-to-net-object – Kyle Delaney Aug 21 '20 at 17:05