LuisDialog returns error after BotAddedToConversation to any message
Hi after I successfully have my response from BotAddedToConversation message I have the following error displayed as a response in my simulator;
{
"message": "An error has occurred.",
"exceptionMessage": "invalid need: expected Wait, have Done",
"exceptionType": "Microsoft.Bot.Builder.Internals.Fibers.InvalidNeedException",
"stackTrace": " at Microsoft.Bot.Builder.Internals.Fibers.Wait`1.ValidateNeed(Need need)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Wait`1.Microsoft.Bot.Builder.Internals.Fibers.IWait.Post[D](D item)\r\n at Microsoft.Bot.Builder.Internals.Fibers.Extensions.Post[T](IFiber fiber, T item)\r\n at Microsoft.Bot.Builder.Dialogs.Internals.DialogContext.<Microsoft-Bot-Builder-Dialogs-Internals-IUserToBot-SendAsync>d__20.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at MyApp.MessagesController.<Post>d__0.MoveNext() in C:\\dev\\projects\\other\\msusur\\jupi-bot\\Jupi.App\\Controllers\\MessagesController.cs:line 28\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
here is my luis dialog. What might go wrong?
[LuisModel("my model id", "subscription key")]
[Serializable]
public class MyQueryDialog : LuisDialog
{
[LuisIntent("LoadLinks")]
public async Task ProcessLinkRequest(IDialogContext context, LuisResult result)
{
var entities = new List<EntityRecommendation>(result.Entities);
if (entities.Count == 0)
{
await context.PostAsync("Thank you!");
}
context.Wait(MessageReceived);
}
}
Here is how I handle the messages
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
return await Conversation.SendAsync(message, () => new MyQueryDialog(BuildForm));
}
return HandleSystemMessage(message);
}
private static IForm<QueryModel> BuildForm()
{
var builder = new FormBuilder<QueryModel>();
return builder.AddRemainingFields().Build();
}
You would see that error if your ProcessLinkRequest (for example) did not wait on MessageReceived at the end of the method. If you reset the dialog state for the conversation (for example, by assigning message.BotPerUserInConversationData = null), does it reproduce?
@willportnoy fixed with the following code. I am not sure if this is the right way though...
public async Task<Message> Post([FromBody]Message message)
{
if (message.Type == "Message")
{
message.BotPerUserInConversationData = null;
return await Conversation.SendAsync(message, () => new SozlukQuery(BuildForm));
}
return HandleSystemMessage(message);
}
Is the Model ID the same as the LUIS app id?
It's the ID that shows up the LUIS query url - the website will provide it to you.
queryString["id"] = this.model.ModelID;
queryString["subscription-key"] = this.model.SubscriptionKey;
queryString["q"] = text;
Thank you!