microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

Facebook and Web chat do not work - V3 #648

Closed shloak closed 8 years ago

shloak commented 8 years ago

After migrating to V3 and changing settings in bot framework portal, Facebook and webchat are not working. When I test connection on the portal, it says the endpoint authorization succeeded and my c# code works on my local machine through the emulator. However, Facebook messenger, which was working with V1, now gives the error "sorry, bot name is having a problem responding right now", and web chat does not return a response. I am using an Azure web app to host the bot.

alex182 commented 8 years ago

I am having the same issue (C#, V3).

Facebook, Groupme, and Telegram webchats return "sorry, bot name is having a problem responding right now".

While Kik, Twilio, Skype, and Slack do not return a response.

When I test my bot connection on dev.botframework.com I get a response of "accepted"

When ran using the local emulator it works fine if I leave MicrosoftAppId and MicrosoftAppPassword blank in the web.config file.

I've attempted to follow this guide but the Emulator does not have a field for the botID.

rmatosaw commented 8 years ago

Same for me. It is related to some kind of permission. This error occurs when answering messages:

System.UnauthorizedAccessException: Security token for MicrosoftAppId: xxxxxxx is unauthorized to post to connector! at Microsoft.Bot.Connector.JwtTokenRefresher.d2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Connector.Conversations.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Bot.Connector.ConversationsExtensions.d__15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at N.OC.Bot._3.MessagesController.d__0.MoveNext()

msft-shahins commented 8 years ago

@alex182 and @rmatosaw can you try with the updated version of nuget v3.0.1 and see if it solves the problem? We had a bug in the MicrosoftAppCredentials implementation that should be fixed in the new package.

rmatosaw commented 8 years ago

Hi. Thanks for the tip. After upgrade, I have a different problem, about references as mentioned in the other post:

InternalServerError { "message": "An error has occurred.", "exceptionMessage": "Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.", "exceptionType": "System.TypeLoadException", "stackTrace": " at Microsoft.Bot.Connector.BotAuthentication.d16.MoveNext()\r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)\r\n at Microsoft.Bot.Connector.BotAuthentication.OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken cancellationToken)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.d2.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.d__1.MoveNext()" }

Also, the upgrade is not easy, because the reference to Bot.Connector needs to be removed manually. I don't know if I did it right.

msft-shahins commented 8 years ago

@rmatosaw how do you end up with this dependency: 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35'? Bot builder nuget is dependent on id="System.IdentityModel.Tokens.Jwt" version="4.0.2.206221351". Is it the case that you have another dependency that relies on a newer version of System.IdentityModel.Tokens.Jwt.

Also upgrade shouldn't be hard, just use nuget package manager to update the nuget and it automatically update all the dependencies.

alexsorokoletov commented 8 years ago

3.0.1 made facebook work for me, node.js

rmatosaw commented 8 years ago

Removed all the references and added again, by nuget. After rewrite some references in web.config it worked! Thanks a lot. The only problem still occurring: in the bot site: error 500 for skype and alerts for all of the other channels. Thanks

0GiS0 commented 8 years ago

Hi folks,

I've updated to 3.0.1 for Node.JS but Webchat doesn't work (no answer). Skype and Telegram work fine.

Thanks,

alex182 commented 8 years ago

@msft-shahins that did it. thanks for the quick response!

msft-shahins commented 8 years ago

@rmatosaw can you elaborate on the issue that you are seeing? your bot works locally against emulator but it deosn't work with skype and other channels? what is your MicrosoftAppId?

msft-shahins commented 8 years ago

@0GiS0 what is the MicrosoftAppId for your bot? Is Webchat still not working for your bot?

AmineI commented 8 years ago

Same here, Facebook is now working but nothing new about WebChat : It understands and receive my message since I see logs in the Azure Web Console, but no messages are sent from the bot in the Webchat. The bot works locally with the emulator and with Facebook like I said 😄 . MicrosoftAppId : bb30223f-2e12-422f-bc7a-4f92d9388600 Hope it helps !

wtam commented 8 years ago

I'm using nodejs and have the following error when try to configure the facebook messenger (note: I already using nuguet 3.0.1

Server Error in '/' Application.

The remote server returned an error: (400) Bad Request. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (400) Bad Request.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[WebException: The remote server returned an error: (400) Bad Request.] Microsoft.WindowsAzure.Storage.Table.Protocol.TableOperationHttpResponseParsers.TableOperationPreProcess(TableResult result, TableOperation operation, HttpWebResponse resp, Exception ex) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\Protocol\TableOperationHttpResponseParsers.cs:53 Microsoft.WindowsAzure.Storage.Table.<>cDisplayClass4.b2(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\TableOperation.cs:133 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse(IAsyncResult getResponseResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:299

[StorageException: The remote server returned an error: (400) Bad Request.] Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync(IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:50 Microsoft.WindowsAzure.Storage.Table.CloudTable.EndExecute(IAsyncResult asyncResult) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:95 Microsoft.WindowsAzure.Storage.Core.Util.<>cDisplayClass1`1.b0(IAsyncResult ar) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Util\AsyncExtensions.cs:66 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Intercom.Azure.Helpers.d10`1.MoveNext() in C:\a\1\s\Utilities\Intercom.Storage.Helpers\CloudTableEntityExtensions.cs:245 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Intercom.Azure.Helpers.d31.MoveNext() in C:\a\1\s\Utilities\Intercom.Storage.Helpers\CloudTableEntityExtensions.cs:71 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +11532712 FacebookChannel.Models.<AddClientCredentials>d__2.MoveNext() in C:\a\1\s\Channels\FacebookChannel\Models\CredentialManager.cs:97 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.Bot.ChannelSDK.<AddClient>d__21.MoveNext() in C:\a\1\s\Channels\IntercomChannelSDK\BaseDevController.cs:250 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +22 System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129

0GiS0 commented 8 years ago

@msft-shahins mi MicrosoftAppId is d5f732f3-c3b0-4093-affc-1d320d4eae4c and still not working. But it happens with all my bots for the WebChat. My bots work well in Skype and Telegram.

Thanks

msft-shahins commented 8 years ago

@AmineI and @0GiS0 we are tracking the issue with WebChat.

@wtam are you using node.js or c# (you mention both nuget and node.js in your question)? Can you attach the debugger and see when connector service is returning 400?

dandriscoll commented 8 years ago

I've got two bugfixes and some additional tracing in place in the WebChat service now. Can you try again with the same app ID and let me know what the result is? Even if it fails, I'll have more data to get this working.

wtam commented 8 years ago

I'm not sure how to attach the debugger as I use the bot channel web portal to configure. My appid 379a3e85-2a5b-4fa1-a1e7-45b6a9df278c and I just try again and still the same error. fyi the app work on skype

AmineI commented 8 years ago

Just tried again, it works here :) ! The chat user name is set to something random like "LJX9NYlUT6F", by the way. -- It's a different issue, but, is there any way we could change that user name before launching the chat ?

wtam commented 8 years ago

I'm very sorry for stupid mistake, I made mistake on my Facebook ID and after correcting it. It's working now. The fault is on myside but if the error return provide some friendly msg in future, it will help some of us to find out where goes wrong.

dandriscoll commented 8 years ago

Hi everyone- Many of the reports on this thread are about the C# version of the SDK. We've updated the C# Nuget package to include fixes for auth reliability, please take a look at 3.1.0. The Node version was updated roughly a week prior. Thanks --Dan