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

Botbuilder not working with MSTEAMS [400] Bad Request

Open bpedersen opened this issue 9 years ago • 8 comments

Thursday there was an update to MSTeams which seems to have broken our app. The bot responds properly in Slack, and my local Emulator, but not in MSTeams. I get the following error on my server.

2017-03-06T22:38:10.069910+00:00 heroku[router]: at=info method=POST path="/api/messages" host=<myapp>.herokuapp.com request_id=03bf9559-200b-4d58-a5ce-a03000eea7c6 fwd="13.68.16.246" dyno=web.1 connect=2ms service=17ms status=202 bytes=100
2017-03-06T22:38:10.186260+00:00 app[web.1]: Error: Request to 'https://state.botframework.com/v3/botstate/msteams/conversations/a%3A1GQeTOsKo8_0momNIECs6UJJ9F94bZQgIcqfsPlgo4e0sbB18xeK2yPWJk5WT9OgVeO5kr0lwqc5IxsCzMNSvQABi9MfhtCIuEAqsr2wLwCAyALYuS5k2zDDyGy3x1fFK/users/29
%3A1TO_yzsNt0RKZ_XR-tLH_50q8802I3o5D5XrH66Lyj1ZYrliOBt-nxiHO4l0OzuQ0Ole23GeQUxlZL4HkGFXbaA' failed: [400] Bad Request
2017-03-06T22:38:10.186279+00:00 app[web.1]:     at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:452:46)
2017-03-06T22:38:10.186280+00:00 app[web.1]:     at Request.self.callback (/app/node_modules/request/request.js:186:22)
2017-03-06T22:38:10.186281+00:00 app[web.1]:     at emitTwo (events.js:106:13)
2017-03-06T22:38:10.186282+00:00 app[web.1]:     at Request.emit (events.js:191:7)
2017-03-06T22:38:10.186283+00:00 app[web.1]:     at Request.<anonymous> (/app/node_modules/request/request.js:1081:10)
2017-03-06T22:38:10.186283+00:00 app[web.1]:     at emitOne (events.js:96:13)
2017-03-06T22:38:10.186284+00:00 app[web.1]:     at Request.emit (events.js:188:7)
2017-03-06T22:38:10.186285+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1001:12)
2017-03-06T22:38:10.186285+00:00 app[web.1]:     at IncomingMessage.g (events.js:291:16)
2017-03-06T22:38:10.186286+00:00 app[web.1]:     at emitNone (events.js:91:20)

I have registered a new bot app to see if that would work and it does work, but I need to use the old App ID. I even tried to create a new password for the old App, but it still throws the same error.

bpedersen avatar Mar 06 '17 22:03 bpedersen

Having same problem. Works in Skype but MS Teams gave error:

Error: Request to 'https://state.botframework.com/v3/botstate/msteams/conversations/xxx/users/xxx' failed: [400] Bad Request
2017-03-07T01:04:37.930726+00:00 app[web.1]:     at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:452:46)
2017-03-07T01:04:37.930726+00:00 app[web.1]:     at Request.self.callback (/app/node_modules/request/request.js:187:22)
2017-03-07T01:04:37.930727+00:00 app[web.1]:     at emitTwo (events.js:106:13)
2017-03-07T01:04:37.930728+00:00 app[web.1]:     at Request.emit (events.js:191:7)
2017-03-07T01:04:37.930729+00:00 app[web.1]:     at Request. (/app/node_modules/request/request.js:1126:10)
2017-03-07T01:04:37.930729+00:00 app[web.1]:     at emitOne (events.js:96:13)
2017-03-07T01:04:37.930730+00:00 app[web.1]:     at Request.emit (events.js:188:7)
2017-03-07T01:04:37.930730+00:00 app[web.1]:     at IncomingMessage. (/app/node_modules/request/request.js:1046:12)
2017-03-07T01:04:37.930731+00:00 app[web.1]:     at IncomingMessage.g (events.js:291:16)
2017-03-07T01:04:37.930732+00:00 app[web.1]:     at emitNone (events.js:91:20)

vusters avatar Mar 07 '17 01:03 vusters

My Teams bot seems to be working consistently again.

alex182 avatar Mar 09 '17 13:03 alex182

MS Teams is now working. Thank you for the fix.

vusters avatar Mar 09 '17 14:03 vusters

Same here.

Skype gives back this strange error, cannot figure out the reason. Code works fine locally with the Emulator.

2017-03-09T20:20:48.312295+00:00 app[web.1]: Error: Request to 'https://smba.trafficmanager.net/apis/v3/conversations/[Id]/activities' failed: [400] Bad Request
2017-03-09T20:20:48.312306+00:00 app[web.1]:     at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:452:46)
2017-03-09T20:20:48.312307+00:00 app[web.1]:     at Request.self.callback (/app/node_modules/request/request.js:186:22)
2017-03-09T20:20:48.312308+00:00 app[web.1]:     at emitTwo (events.js:106:13)
2017-03-09T20:20:48.312309+00:00 app[web.1]:     at Request.emit (events.js:191:7)
2017-03-09T20:20:48.312310+00:00 app[web.1]:     at Request.<anonymous> (/app/node_modules/request/request.js:1081:10)
2017-03-09T20:20:48.312310+00:00 app[web.1]:     at emitOne (events.js:96:13)
2017-03-09T20:20:48.312311+00:00 app[web.1]:     at Request.emit (events.js:188:7)
2017-03-09T20:20:48.312312+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1001:12)
2017-03-09T20:20:48.312312+00:00 app[web.1]:     at IncomingMessage.g (events.js:291:16)
2017-03-09T20:20:48.312313+00:00 app[web.1]:     at emitNone (events.js:91:20)

izzyleung avatar Mar 09 '17 20:03 izzyleung

We've been making quite a few changes in the last few months but should be in a stable state now. Based on the messages above, looks like the issues were due to a break on our serviceURL, since fixed. (You should always be hitting: https://smba.trafficmanager.net

RichMoeMSFT avatar Mar 10 '17 14:03 RichMoeMSFT

I'm getting the error both with MS Teams and Skype:

Error: Request to 'https://smba.trafficmanager.net/apis/v3/conversations/[ID]/activities' failed: [400] Bad Request
    at Request._callback (D:\home\site\wwwroot\node_modules\botbuilder\lib\bots\ChatConnector.js:452:46)
    at Request.self.callback (D:\home\site\wwwroot\node_modules\request\request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (D:\home\site\wwwroot\node_modules\request\request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (D:\home\site\wwwroot\node_modules\request\request.js:1091:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)

Haven't tested with Slack, but Bot emulator and web works.

juhamust avatar Mar 13 '17 14:03 juhamust

@PiereDome @vusters your issues are related to the state api, not the messaging one, so there are 2 issues reported in this thread. The state one seems to be resolved.

@juhamust @izzyleung when sending messages to msteams you should make a response call to the service url value you get from the original activity sent from the user to your bot).

Some examples of valid service urls for msteams are: https://smba.trafficmanager.net/amer-client-ss.skype.msg/ https://smba.trafficmanager.net/emea-client-ss.skype.msg/

You are using /apis/ which is probably hardcoded (or cached) somewhere in your bot code. Here are the docs for service url usage: https://docs.botframework.com/en-us/csharp/builder/sdkreference/routing.html

konstlut avatar Mar 14 '17 09:03 konstlut

I think we have fixed this issue. It turns out Teams URLs are longer then most urls and some of them were exceeding the configured max url length for the service. We deployed configuration updates yesterday. Please reopen if you still see issue after today

tomlm avatar Mar 14 '17 16:03 tomlm