3

I'd like to use a chain interface as my root dialog to switch the conversation by the user message, for example I can call a HelpDialog if the user write 'help' and let the other inputs managed by the LuisDialog.

My problem is that the LuisDialog wait for a message from the user so, in a chain enviroment, the user must write twice the input before the Luis return one of his intent.

This is my example code:

public static readonly IDialog<string> dialog = Chain
        .PostToChain()
        .Switch(
            new Case<IMessageActivity, IDialog<string>>(msg =>
                {
                    var regex = new Regex("^help$", RegexOptions.IgnoreCase);
                    return regex.IsMatch(msg.Text);
                },
                (ctx, msg) =>
                {
                    return new HelpDialog();
                }),

            new DefaultCase<IMessageActivity, IDialog<string>>(
                (ctx, msg) => {
                    return new MyLuisDialog();
                })
        )           
        .Unwrap().PostToUser();

Is it possible to use LuisDialog with Chain or how can I use multiple Dialogs together?

Thanks Marco

  • One of the best solution for chaining the dialog can be using context.forward and context.call inside the dialog when you need. – OmG Dec 07 '16 at 14:36

1 Answers1

0

To use, context.Forward and context.Call requires to create a new class implementing the IDialog.

If you won't like to do it, try the below code in your LuisDialog implementation. It works!

public override async Task StartAsync(IDialogContext context)
    {
        await this.MessageReceived(context, Awaitable.FromItem(context.Activity.AsMessageActivity()));
    }
  • When I do that, and complete the forwarded dialog with context.done it returns to my completion method for which I then also call context.Done. However it then starts right back up again coming back into the LuisDialog that was used to kick it off. Solutions? – James Hancock Dec 06 '17 at 18:21