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

Sorry, my bot code is having an issue.

Open stucko opened this issue 10 years ago • 2 comments

I am currently getting this as a reply when testing my bot in the Emulator. Ive checked the bot app logs and there arent any errors. What kind of issue would this be?

Here is the part code that is causing this:

private async Task LogIn(IDialogContext context)
        {
            string token;
            if (!context.PrivateConversationData.TryGetValue(AuthTokenKey, out token))
            {
                context.PrivateConversationData.SetValue("persistedCookie", ResumptionCookie);

                Activity loginActivity = new Activity();
                loginActivity= loginActivity.CreateReply("Logging In");
                Trace.TraceInformation($"loginActivity Type : {loginActivity.Type}");
                Trace.TraceInformation($"loginActivity Action : {loginActivity.Action}");
                Trace.TraceInformation($"loginActivity Text : {loginActivity.Text}");

                await context.PostAsync(loginActivity);
                context.Wait(MessageReceivedAsync);
            }
            else
            {
                context.Done(token);
            }
        }

While this works :

private async Task LogIn(IDialogContext context)
        {
            string token;
            if (!context.PrivateConversationData.TryGetValue(AuthTokenKey, out token))
            {
                context.PrivateConversationData.SetValue("persistedCookie", ResumptionCookie);
                string fbLogin = $"Go to: {FacebookHelpers.GetFacebookLoginURL(ResumptionCookie, FacebookOauthCallback.ToString())}";

                await context.PostAsync(fbLogin);
                context.Wait(MessageReceivedAsync);
            }
            else
            {
                context.Done(token);
            }
        }

cant i pass an Activity type to PostAsync, isnt Activity type an IActivityMessage ? im trying to use cards in dialog.

stucko avatar Aug 09 '16 02:08 stucko

We added that error message so that it was obvious that the http request to post a user's message to the bot was failing with an unhandled exception:

https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Dialogs/DialogTask.cs#L443

even if all of the previous messages were successfully sent. Do you see your reply message?

willportnoy avatar Aug 09 '16 20:08 willportnoy

thanks got to see it with the debugger attached , I have yet to solve my problem, but i guess this solves the "Sorry, my bot code is having an issue" issue, thanks :)

" at Microsoft.Bot.Connector.ConversationsExtensions.ReplyToActivityAsync(IConversations operations, Activity activity, CancellationToken cancellationToken)\r\n at Microsoft.Bot.Builder.Dialogs.Internals.AlwaysSendDirect_BotToUser.d__4.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.DialogContext.d__10.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.GetResult()\r\n at StuckoBot_Application.SimpleFacebookAuthDialog.d__7.MoveNext() in F:\WORK\00 StuckoDev\StuckoBot Application\StuckoBot Application\StuckoBot Application\SimpleFacebookAuthDialog.cs:line 224"

stucko avatar Aug 09 '16 23:08 stucko