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;
}
[LuisIntent("Greeting")]
public async Task GreetingIntent(IDialogContext context, LuisResult result)
{
await this.ShowLuisResult(context, result);
}
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:
