botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

error: invalid need: expected Call, have Wait

Open dipumon opened this issue 10 years ago • 2 comments

I am getting the above mentioned error, when I am trying to build a simple conversational bot. The following is the code which I trying to implement.

public async Task<Message> Post([FromBody]Message message)
    {
        if (message.Type == "Message")
        {
            // return our reply to the user
            return await Conversation.SendAsync(message, () => new EchoDialog());
        }
        else
        {
            return HandleSystemMessage(message);
        }
    }

[Serializable]
public class EchoDialog : IDialog<object>
{
    protected int count = 1;
    public async Task StartAsync(IDialogContext context)
    {
        context.Wait(MessageReceivedAsync);
    }
    public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> argument)
    {
        var message = await argument;
        message query = message.Text();

        response = call_LUIS(query);        //function to call luis and return the response
!--
Here function for parsing the JSON response and storing it in variables x and y.
--!

    if(x == 0)
    {
        await context.PostAsync("Please enter the correct input for x:");
        context.Wait(MessageReceivedAsync);
    }

    if(y == 0)
    {
        await context.PostAsync("Please enter the correct input for y:");
        context.Wait(MessageReceivedAsync)
    }

    await context.PostAsync("The End");
    context.Wait(MessageReceivedAsync);

    }

}

The messages in loop if(x==0) and if(y==0) are not executed and only thing I am getting is the above mentioned error.

dipumon avatar Jun 27 '16 05:06 dipumon

I believe that error would occur only if context.Wait was called twice within the same method without actually returning from the method to allow the user to send a message.

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Fibers/Fiber.cs#L101

willportnoy avatar Jun 27 '16 20:06 willportnoy

I'm going to close this issue for now, but feel free to re-open another issue if you have more questions.

willportnoy avatar Jul 05 '16 15:07 willportnoy