I receive exception in emulator, when doing EchoBot with Bot Builder exactly as shown in documentation. (EchoDialog is copy pasted)
Message and stack-trace are not very informative. I can't understand what exactly is wrong in my code.
The same project works well if I do it without Bot Builder.
{
"message": "An error has occurred.",
"exceptionMessage": "invalid need: expected Wait, have Done",
"exceptionType": "Microsoft.Bot.Builder.Internals.Fibers.InvalidNeedException",
"stackTrace": " Π² Microsoft.Bot.Builder.Internals.Fibers.Wait`1.ValidateNeed(Need need)\r\n Π² Microsoft.Bot.Builder.Internals.Fibers.Wait`1.Microsoft.Bot.Builder.Internals.Fibers.IWait.Post[D](D item)\r\n Π² Microsoft.Bot.Builder.Internals.Fibers.Extensions.Post[T](IFiber fiber, T item)\r\n Π² Microsoft.Bot.Builder.Dialogs.Internals.DialogContext.<Microsoft-Bot-Builder-Dialogs-Internals-IUserToBot-SendAsync>d__20.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² Microsoft.Bot.Builder.Dialogs.Conversation.<SendAsync>d__2.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n Π² Bot.Controllers.MessagesController.<Post>d__0.MoveNext() Π² C:\\work\\TsyaBot\\Bot\\Controllers\\MessagesController.cs:ΡΡΡΠΎΠΊΠ° 22\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- ΠΠΎΠ½Π΅Ρ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΠ° ΡΡΠ΅ΠΊΠ° ΠΈΠ· ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π³ΠΎ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, Π³Π΄Π΅ Π²ΠΎΠ·Π½ΠΈΠΊΠ»ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ---\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n Π² System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n Π² System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}
Try starting a new conversation by changing the conversation ID. You would see this exception if your code finished without calling something like context.Wait(MessageReceived). We'll work to improve the error message.
Please re-open this issue if you've tried Will's suggestion and are still seeing an exception.
I believe the solution is to clear your user profile by sending the framework a /deleteprofile message.
Good luck!
-r
I had a similar issue and Will's solution worked, but I'm curious as to why this happens and how I can prevent the code from finishing before it calls context.Wait(MessageRecieved). Any ideas?
I recently added a commit https://github.com/Microsoft/BotBuilder/commit/fa07e71774fc3e8ed7e943f22f48b891e806f32a (with some tests) to translate this exception to something more intelligible.
If you want to ensure that context.Wait(MessageReceived) is always called within a method, you can use a finally block or implement a IDisposable struct scoped to a using-block.
But it's not always what you want to do, because you may have some other method you'd like to received the next message into, to model some sort of state machine.
If you're using the LuisDialog, you might consider deriving from it and overriding the MessageReceived to call the base implementation then call context.Wait(MessageReceived), but that presumes you don't have more complicated state you want to track.
okay. I opened another issue that's more specific to my problem than this thread. Thanks for your input
@willportnoy I get this error when I call the bot from slack. It works in emulator after executing deleteprofile command but I am not able to get rid of this error when I call it from slack. How can I delete profile or clear state from previous conversation and start a new one?
_Update:_ I tried to make the same conversation with bot using different slack user and it worked for the first time. It gives the same error again with this new user when I tried to do it 2nd time. The issue here I think is that I have got some error with both the users performing some action that only worked first time. The conversation got into a hanged state right then. Is there a way I can clear the earlier context of the user-bot conversation and make it a fresh start every time bot is called by any user?
You need to add a space before /deleteprofile so that it's not interpreted by slack.
I'm going to close this issue for now, but feel free to open a new issue with further questions.
i tried making a small bot but facing this error....
{
"message": "An error has occurred.",
"exceptionMessage": "Response status code does not indicate success: 400 (Bad Request).",
"exceptionType": "System.Net.Http.HttpRequestException",
"stackTrace": " at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Bot.Builder.Luis.LuisService.1.<MessageReceived>d__6.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.Internals.DialogTask.ThunkResume1.2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.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.Internals.Fibers.Frame1.1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.Bot.Builder.Internals.Fibers.Wait2.Microsoft.Bot.Builder.Internals.Fibers.IAwaiter1.<ResumeAsync>d__3.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.Internals.DialogTask.ThunkResume1.2.<Microsoft-Bot-Builder-Internals-Fibers-IWait<C>-PollAsync>d__19.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.Internals.Fibers.Frame1.1.<Microsoft-Bot-Builder-Internals-Fibers-IFiberLoop<C>-PollAsync>d__13.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.Internals.DialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__211.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.Internals.ReactiveDialogTask.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 Microsoft.Bot.Builder.Dialogs.Internals.LocalizedDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__21.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.Internals.ScoringDialogTask1.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__61.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.Internals.PersistentDialogTask.1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.Bot.Builder.Dialogs.Internals.PersistentDialogTask.<Microsoft-Bot-Builder-Dialogs-Internals-IPostToBot-PostAsync>d__61.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.
}
my LUIS code is as follows....
using CourseData;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
namespace chatbot
{
[LuisModel("", "")]
[Serializable]
public class LUISDialog : LuisDialog
public static Courses1 champs = new Courses1();
[LuisIntent("CourseCount")]
public async Task GetCourseCount(IDialogContext context, LuisResult result)
{
await context.PostAsync($"there are totally {champs.GetCourseCount()} courses.");
context.Wait(MessageReceived);
}
}
}
facing this same error whenever i tried to connect a bot using LUIS. please help me ASAP... stuck with this
@enojo can you open a new top level issue for your LUIS question?
I have a similar issue with an error message saying:
Exception: invalid need: expected Wait, have Call
It occures in the return function after authbot has authenticated and I am trying to forward the message into the mail dialog. My code:
```
[Serializable]
public class AuthDialog : IDialog
{
public async Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable
{
//original message if we need to resume
var message = await item;
//try to get access token
var token = await context.GetAccessToken("https://graph.microsoft.com/");
if (string.IsNullOrEmpty(token))
{
//invoke the AuthBot to help get authenticated
await context.Forward(new AzureAuthDialog("https://graph.microsoft.com/"), this.resumeAfterAuth, message, CancellationToken.None);
}
else
{
//token exists...forward to GraphDialog
await context.Forward(new RootDialog(), null, message, CancellationToken.None);
}
}
private async Task resumeAfterAuth(IDialogContext context, IAwaitable<string> result)
{
//post the response message and then go back into the MessageReceivedAsync flow
var message = await result;
await context.PostAsync(message);
//now that token exists...forward to GraphDialog
await context.Forward(new RootDialog(), null, message, CancellationToken.None);
context.Wait(MessageReceivedAsync);
}
}
}```
@nornes Can you please open a new issue or post on stack overflow for this?
@nornes : can you let me know how you have resolved the above issue??
I am also using AuthBot package for authentication, and my bot flow is similar to yours.
When access token is not present after authentication I get the same error as you i.e. Exception: invalid need: expected Wait, have Call.
Thanks in advance!
Most helpful comment
Try starting a new conversation by changing the conversation ID. You would see this exception if your code finished without calling something like context.Wait(MessageReceived). We'll work to improve the error message.