0
votes

I'm trying to pass the user name that i have in Rootdialog to my LuisDialog. but all the intents in LuisDialog accepts only two arguments (IDialogContext context, LuisResult result)and i don't know how to retrieve the data that i have passed from `LuisResult result. The code to forward to a luis dialog is this :

await context.Forward(new Luis(), Resume, UserName, CancellationToken.None);

How can i do this please ? which intent will recieve the data ? how can i retrive data from LuisResult object ?

1
It's unclear: you want to pass data from your RootDialog to your LuisDialog, or you want to get data from your LuisResult?Nicolas R
I want to pass data from my RootDialog to my LuisDialog and retrieve this data in my LuisDialogSoufien Hajji

1 Answers

1
votes

I'm trying to pass the user name that i have in Rootdialog to my LuisDialog.

You can try to define a constructor in your LuisDialog class to accept string type parameter for passing the username from Rootdialog to LuisDialog. The following code snippet works for me, you can refer to it.

In LuisDialog:

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

    private string uname = "";

    public BasicLuisDialog(string UserName) : base(new LuisService(new LuisModelAttribute(
        "{your_modelID_here}",
        "{your_subscriptionKey_here}", 
        domain: "{domain_here}")))
    {
        uname = UserName;
    }

    //....

    // Go to https://luis.ai and create a new intent, then train/publish your luis app.
    // Finally replace "Gretting" with the name of your newly created intent in the following handler
    [LuisIntent("Greeting")]
    public async Task GreetingIntent(IDialogContext context, LuisResult result)
    {
        await this.ShowLuisResult(context, result);
    }

    //....
    //for other intents
    //.... 

    private async Task ShowLuisResult(IDialogContext context, LuisResult result) 
    {
        await context.PostAsync($"You have reached {result.Intents[0].Intent}. UserName is : {uname}");
        context.Wait(MessageReceived);
    }
}

In RootDialog:

var UserName = "Fei Han";
await context.Forward(new BasicLuisDialog(UserName), AfterLuis, activity, CancellationToken.None);

Test result:

enter image description here