garypretty / botframework

Microsoft Bot Framework helpers and additional dialogs
MIT License
60 stars 51 forks source link

Example does not compile #4

Closed felipe-pereira-xpantion closed 7 years ago

felipe-pereira-xpantion commented 7 years ago

Hi, when using the dialog as in the example:

        [LuisIntent("")]
        public async Task None(IDialogContext context, LuisResult result)
        {
            var dialog = new CommonResponsesDialog();
            dialog.InitialMessage = result.Query;
            context.Call(dialog, AfterCommonResponseHandled);
        }

        public async Task AfterCommonResponseHandled(IDialogContext context, IAwaitable<bool> result)
        {
            var messageHandled = await result;

            if (!messageHandled)
            {
                await context.PostAsync("I’m not sure what you want");
            }

            context.Wait(MessageReceived);
        }

I get Error CS1503 Argument 2: cannot convert from 'method group' to 'ResumeAfter' In: context.Call(dialog, AfterCommonResponseHandled);

Any clues about this?

Thanks

felipe-pereira-xpantion commented 7 years ago

Looks like it could be changed to

public async Task AfterCommonResponseHandled(IDialogContext context, IAwaitable<object> result)
{

    var messageHandled = await result;

    if (!bool.Parse(messageHandled.ToString()))
    {
        await context.PostAsync("I’m not sure what you want");
    }

    context.Wait(MessageReceived);
}

It still works this way

didaskein commented 7 years ago

Check to have : public class GreetingsDialog : BestMatchDialog<bool>

and not public class GreetingsDialog : BestMatchDialog<object>

garypretty commented 7 years ago

Hi. Apologies for the late reply, I have been pretty busy. When you use the BestMatchDialog as your root dialog then the definition should be

public class GreetingsDialog : BestMatchDialog

If you want to use it as a child dialog and return a bool to the resume after method (AfterCommonResponseHandled in the example), then you change the definition to

public class GreetingsDialog : BestMatchDialog.

I agree that this is not clear in the readme, so I will update accordingly. Thanks for spotting it and let me know if this doesn't resolve the issue and I can re-open.