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

[Node.js SDK] Session.endConversation() causes [400] Bad Request and no username

Open SeanSobey opened this issue 8 years ago • 9 comments

Bot Info

  • SDK Platform: Node.js
  • SDK Version: 3.15.0
  • Active Channels: Skype
  • Deployment Environment: Local via ngrok

Issue Description

An endConversation causes a '400' POST and after this the session.message.user.name is undefined. Error: POST to 'https://smba.trafficmanager.net/apis/v3/conversations/29%3A12fMgeiJDkMJmp5SXwnHt7tJf7sl3sst22-FBErf-7mY/activities' failed: [400] Bad Request

Code Example

// in a middleware function
return {
	botbuilder: (session, next) => {

		if (session.message.text) {
			const match = /test/i.exec(session.message.text);
			if (!match) {
				return next();
			}
			return session.endConversation(message);
		}
		return next();
	}
};

Reproduction Steps

  1. Connect to bot using Skype via ngrok.
  2. type 'test'. Notice a breakpoint in the middeware function will have a populated session.message.user.name.
  3. The bot will emit an error, see below.
  4. The next time a message is recieved in the middleware session.message.user.name is undefined.

Expected Behavior

No error and the user address

Actual Results

Error: POST to 'https://smba.trafficmanager.net/apis/v3/conversations/29%3A12fMgeiJDkMJmp5SXwnHt7tJf7sl3sst22-FBErf-7mY/activities' failed: [400] Bad Request

Here is the options var for ChatConnector.prototype.postMessage right before the error:

{
	"method": "POST",
	"url": "https://smba.trafficmanager.net/apis/v3/conversations/29%3A12fMgeiJDkMJmp5SXwnHt7tJf7sl3sst22-FBErf-7mY/activities",
	"body": {
		"type": "endOfConversation",
		"code": "completedSuccessfully",
		"localTimestamp": "2018-06-08T09:46:49.900Z",
		"from": {
			"id": "28:1c62f3fd-9eed-45e4-b9dd-c6c32cd0600e",
			"name": "<Some Name>"
		},
		"recipient": {
			"id": "29:12fMgeiJDkMJmp5SXwnHt7tJf7sl3sst22-FBErf-7mY"
		}
	},
	"json": true
}

SeanSobey avatar Jun 08 '18 10:06 SeanSobey

Hi @SeanSobey,

Please review the docs listed here as they should help in understanding what is happening.

In short, because the conversation is ended, per the text match in the middleware, there is nothing to be reported back when "The next time a message is received". The dialog stack has been cleared at this point and a 400 error is returned.

My suggestion is to build the .endConversation into the dialog flow as demonstrated in the docs. I'm closing this as I believe this solves your problem. Please reopen if you have additional related questions.

Steve.

stevkan avatar Jun 08 '18 20:06 stevkan

Hi @stevkan, thanks for your reply.

My example was based off the Middleware.dialogVersion included in the SDK which also results in a 400 error:

bot.use(Middleware.dialogVersion({
	version: 0.0,
	resetCommand: /^reset$/i
}))

Error: POST to 'https://smba.trafficmanager.net/apis/v3/conversations/29%3A12fMgeiJDkMJmp5SXwnHt7tJf7sl3sst22-FBErf-7mY/activities' failed: [400] Bad Request

Note this only happens in Skype not via the Emulator, Slack or Messenger. This still appears to be a bug?

SeanSobey avatar Jun 12 '18 12:06 SeanSobey

Hi @SeanSobey, I just saw you had responded. Let me take another look and will get back to you.

stevkan avatar Jun 21 '18 23:06 stevkan

@stevkan this still appears to be an active bug, has anyone been able to confirm?

SeanSobey avatar Jul 24 '18 12:07 SeanSobey

Hi @SeanSobey,

Yes, I was able to confirm your results. I will mark this as a bug for further consideration.

Thanks, Steve.

stevkan avatar Sep 19 '18 18:09 stevkan

Thanks Steve

SeanSobey avatar Sep 20 '18 07:09 SeanSobey

yeah we're experiencing the same issue

rcc-peters avatar Sep 21 '18 00:09 rcc-peters

wonder if this is related to

https://github.com/Microsoft/BotBuilder/issues/3576

rcc-peters avatar Sep 21 '18 00:09 rcc-peters

Thank you for opening an issue against the Bot Framework SDK v3. As part of the Bot Framework v4 release, we’ve moved all v3 work to a new repo located at https://github.com/microsoft/botbuilder-v3. We will continue to support and offer maintenance updates to v3 via this new repo.

From now on, https://github.com/microsoft/botbuilder repo will be used as hub, with pointers to all the different SDK languages, tools and samples repos.

As part of this restructuring, we are closing all tickets in this repo.

For defects or feature requests, please create a new issue in the new Bot Framework v3 repo found here: https://github.com/microsoft/botbuilder-v3/issues

For Azure Bot Service Channel specific defects or feature requests (e.g. Facebook, Twilio, Teams, Slack, etc.), please create a new issue in the new Bot Framework Channel repo found here: https://github.com/microsoft/botframework-services/issues

For product behavior, how-to, or general understanding questions, please use Stackoverflow. https://stackoverflow.com/search?q=bot+framework

Thank you.

The Bot Framework Team

JasonSowers avatar Oct 01 '18 20:10 JasonSowers