I am leaing to create a bot using Microsoft Bot Framework. I am a newbie in C# programming.
In the following code, I have tried to create a conversational bot. Here, initially the user enters a query, it passed to LUIS api to understand the response. The specific values are stored in variables x and y. If x and y are particular values, then the user is requested to input the values again as shown.
As shown in the code, I am using PostAsync method to post to the bot and awaiting response from the user using context.wait(MessageReceivedAsync). But when my execution goes into if(x==0),it dows not post the message to the user at that instant and also does not wait for the input from the user. But after the execution of complete, the postasync method fires, but suddenly error 500 occurs with the exception messsag: exception need:expected call;got wait.
Can somebody throw light on this problem and tell where I am going wrong. P.S the json parsing from LUIS response is working fine.Only the bot commands are causing a problem.
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
// retu our reply to the user
retu await Conversation.SendAsync(message, () => new EchoDialog());
}
else
{
retu 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 retu 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);
}
}
