error: invalid need: expected Call, have Wait
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.
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
I'm going to close this issue for now, but feel free to re-open another issue if you have more questions.