0

I'm trying to trigger multiple LUIS dialogs based on intent. But the problem I'm facing is once the child dialog is triggered it automatically triggers the callback method in the parent LUIS Dialog.

I've been following this post of SO which mentions the same problem, but am unable to replicate the same success.

Here is my code snippet for reference

[LuisIntent("ClaimStatus")]
public async Task ClaimStatus(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
        string message = "";
        message = "Sure, but first I would need to verify you.";
        await context.PostAsync(message);
        await context.Forward(new VerificationDialog(), VerificationDialogCompleted, context.Activity, CancellationToken.None);
}

private Task VerificationDialogCompleted(IDialogContext context, IAwaitable<object> result)
{
  //var res = await result;
  context.PostAsync("ProductsDialogCompleted" + result);
  context.Wait(MessageReceived);
  return Task.CompletedTask;
}

Code in child dialog

override public async Task StartAsync(IDialogContext context)
{
        await context.PostAsync("Would you please tell me your Customer ID?");
        context.Wait(MessageReceived);
}

[LuisIntent("None")]
private async Task None(IDialogContext context, IAwaitable<IMessageActivity> activity, LuisResult result)
{
    context.Done(true);
}

EDIT1: I have also found a GitHub repo that shows dialogue stacks by the same author in SO but still the LUIS dialog stack is not working as expected.

user6083088
  • 1,047
  • 1
  • 9
  • 27
  • What version of BotBuilder are u using? – Ezequiel Jadib Jul 19 '17 at 11:24
  • @EzequielJadib Microsoft.Bot.Builder v3.8.5 – user6083088 Jul 19 '17 at 11:52
  • @EzequielJadibI here are the message controller, root & child luis dialog as gist https://gist.github.com/PrasenjitGiri/eae50a3cccb7914bcf4eabda16e62309 – user6083088 Jul 19 '17 at 12:01
  • Can you quickly check if this happen if you use v3.8.4? – Ezequiel Jadib Jul 19 '17 at 12:09
  • I downgraded to v3.8.4 but still gets the same message ProductsDialogCompletedWait: Call Object for HCABot.Dialogs.RootLuisDialog.VerificationDialogCompleted.Rest have Object – user6083088 Jul 19 '17 at 12:16
  • this line is commented var res = await result; and the following one should be context.PostAsync("ProductsDialogCompleted" + res); instead of result – Ezequiel Jadib Jul 19 '17 at 12:21
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/149598/discussion-between-user6083088-and-ezequiel-jadib). – user6083088 Jul 19 '17 at 12:23
  • @user6083088 This is not the first report of behavior like this. I posted a [snippet here](https://github.com/Microsoft/BotBuilder/issues/3157) see if that works for you. Additionally, can you post on the thread I linked and explain you are experiencing the same issue. – D4RKCIDE Jul 19 '17 at 15:21
  • @JasonSowers Pardon me, as I'm very new to this. I'm using IDialog & not forms, so are they the same problem? – user6083088 Jul 19 '17 at 15:22
  • They are related in the way in which the forms/dialogs are initiated. – D4RKCIDE Jul 19 '17 at 16:16
  • @EzequielJadib I now found what was going on, when the context.Forward() executes, it prints message in StartAsync() but if I put in a handler for [LuisIntent("")] or [LuisIntent("None")] it is getting triggered even before user has typed in the new Dialog. Basically it is sending the context.Activity from parent to the child Luis dialog and it's calling Luis endpoint. Do you happen to know how we can stop this? – user6083088 Jul 25 '17 at 13:33
  • it's expected since you are using Forward... use Call() if you don't want to execute the dialog inmediately. – Ezequiel Jadib Jul 25 '17 at 14:08
  • 1
    OMG! I've at this for the past 5 days - thank you @EzequielJadib If you add a message I can accept it if you would like. And, how are you reading so much - I dont see these mentioned in the Bot page here https://learn.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-quickstart – user6083088 Jul 25 '17 at 14:13
  • Glad it helped! I just added the answer – Ezequiel Jadib Jul 25 '17 at 14:28

1 Answers1

0

The problem that you are seeing is because you are using context.Forward() which basically initiates a dialog and pass the message through it (without user input).

If you want to avoid that, you need to use just context.Call() which will initiate the dialog but wait for a message from the user.

You can review this to know more: Calling Forms from Dialogs

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43