Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot convert from 'method group' to 'ResumeAfter<object>'

I'm trying to create a child dialog from a Luis intent to gather additional information from the user. However I'm receiving a Cannot convert from 'method group' to 'ResumeAfter<object>' error message on the second argument of context.Call

[LuisIntent("Login")]
public async Task LoginIntent(IDialogContext context, LuisResult result)
{
    var serverdialog = new ServerDialog();
    await context.Call(serverdialog, ResumeAfterServerDialog); //error here
}

private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<string> serverName)
{
    this.serverAddress = await serverName;
    await context.PostAsync($"you've entered {this.serverAddress}");
    context.Wait(MessageReceived);
}

The server dialog class is

[Serializable]
public class ServerDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync("Enter your server's name (example: 10.10.10.52)");
        context.Wait(ReceiveServerDialog);
    }

    public async Task ReceiveServerDialog(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
        IMessageActivity message = await result;
        context.Done(message.Text);

    }
}

I found an explanation saying :

the type of the second parameter for MessageReceived is likely IAwaitable, but you need a method with a second parameter of IAwaitable, for example, if you're passing null as the result value and the type of your child dialog is IDialog.

however I couldn't make sense of this.

like image 939
Teragon Avatar asked Apr 21 '17 19:04

Teragon


1 Answers

Your dialog implements IDialog<object> but your ResumeAfter<T> method ReceiveServerDialog is a expecting a string (in IAwaitable<string> serverName parameter)

Change your dialog to implement IDialog<string> or change your ReceiveServerDialog method to be

private async Task ResumeAfterServerDialog(IDialogContext context, IAwaitable<object> serverName)
like image 173
Ezequiel Jadib Avatar answered Sep 30 '22 05:09

Ezequiel Jadib