my goal is to implement both dialogs and LUIS into a Microsoft Bot Framework application using their C# SDK. I tried to follow this thread https://github.com/M
I had this same question, but I am using a newer version of Bot Framework, more specifically, V4.
Here is what I found:
BeginDialogAsync
's options
parameter takes an array of objects that will then be accessible in your dialog. // Get skill LUIS model from configuration.
localizedServices.LuisServices.TryGetValue("MySkill", out var luisService);
if (luisService != null)
{
// Get the Luis result.
var result = innerDc.Context.TurnState.Get<MySkillLuis>(StateProperties.SkillLuisResult);
var intent = result?.TopIntent().intent;
// Behavior switched on intent.
switch (intent)
{
case MySkillLuis.Intent.MyIntent:
{
// result is passed on to my dialog through the Options parameter.
await innerDc.BeginDialogAsync(_myDialog.Id, result);
break;
}
case MySkillLuis.Intent.None:
default:
{
// intent was identified but not yet implemented
await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("UnsupportedMessage"));
break;
}
}
}
From our second dialog, we can access the object through the context and perform any casting, etc. as necessary. In my case, it was a waterfall dialog, so I used stepContext.options
.
Try removing the Chain.From(()
from the context.Forward
call. Not sure why you are adding it, but it shouldn't be there at all.
Try with:
await context.Forward(new ProductsDialog(), ProductsDialogCompleted, context.Activity, CancellationToken.None);
And btw, if the message you forward hits the None
intent the ProductsDialogCompleted
method will be hit because you are doing context.Done
, which basically ends the ProductsDialog
.
Also, have in mind the StartAsync
method is present in the LuisDialog<T>
base class, so you need to add the override
keyword.