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

[AssistantV1] context.metadata object loses message_id parameter upon response

Open aliuspetraska opened this issue 7 years ago • 10 comments

Overview Making call to Assistant endpoint via SDK part of metadata properties are lost.

assistant.message({
	workspace_id: 'workspaceId',
	input: {
		text: 'hello',
	},
	context: {
		metadata: {
      			user_id: '01234567891',
	      		message_id: 'ff554319-5890-4a86-a1e5-7efae9b14f16'
   		}
	}
});

Expected behavior I'm expecting user_id and message_id will be returned as a part of the response.

context: {
	metadata: {
      		user_id: '01234567891',
	      	message_id: 'ff554319-5890-4a86-a1e5-7efae9b14f16'
   	}
}

Actual behavior

message_id is missing.

context: {
	metadata: {
      		user_id: '01234567891'
   	}
}

SDK Version 4.2.2

aliuspetraska avatar Jul 17 '19 09:07 aliuspetraska

Hi @aliuspetraska, why are you expecting to see message_id?

Looking at the "Response" section of the documentation for "message", message_id is not meant to be present in the response:

message-response

dpopp07 avatar Jul 17 '19 14:07 dpopp07

Thanks for a reply @dpopp07, the reason we do need it, is that we do have a chatbot orchestrator which was done based on on previous watson-developer-cloud version, and it was working the way I described, so after updated to the new SDK we are not receiving message_id from the watson.

we are using message_id for message logging, reports, feedback collection for exact responses from watson and etc.

aliuspetraska avatar Jul 17 '19 18:07 aliuspetraska

Okay, I'm still a little confused because it looks like the service itself does not return a message_id regardless of what the SDK is doing. I also don't see that parameter in the previous version of the SDK either. Can you clarify a little more?

@rrberry Was there ever a message_id field returned from "message" in a previous version of the service?

dpopp07 avatar Jul 17 '19 22:07 dpopp07

@dpopp07 I don't know the history ... all I can tell you is that I don't remember ever removing message_id, so I have no reason to believe it was ever there.

rrberry avatar Jul 18 '19 12:07 rrberry

There are no changes to the API doc involving message_id in git history:

[mkistler@mkistlers-mbp] ~/Projects/watson-developer-cloud/api-definitions (master)>git log -S "message_id" apis-public/assistant-v1.json
[mkistler@mkistlers-mbp] ~/Projects/watson-developer-cloud/api-definitions (master)>

mkistler avatar Jul 18 '19 13:07 mkistler

@dpopp07 @rrberry @mkistler the question and the problem is not about is there (or was) message_id in the documentation. The problem is about that previously everything what was added to the metadata object was coming back the same structure, and now it drops everything out except user_id.

From compatibility perspective it looks like breaking change, at least for us :)

aliuspetraska avatar Jul 18 '19 13:07 aliuspetraska

Okay @aliuspetraska I asked around internally some more and found out that

context.metadata had a (breaking) behavioral change in some past API version - where its a "strict" object now that doesn't support custom attributes

This change was brought about on 2018-07-10 - if you specify a version date of anytime before then, you should be able to maintain compatible behavior. Let me know if that works for you

dpopp07 avatar Jul 18 '19 21:07 dpopp07

@aliuspetraska Thanks for the extra context ... I understand now that you are sending a message_id value in context.metadata with the message request and expecting this value to be present in the context.metadata of the response.

Through some testing, I determined that the behavior you report is actually dependent on the version-date (passed in the version parameter) used by the app:

  • for a version-date 2018-07-09 or earlier, additional properties in context.metadata were preserved (sent back) by message
  • if version-date is 2018-07-10 or later, those additional properties are dropped.

I think the behavior of maintaining those additional properties was never documented or "intended" as a feature of the service, so you were relying on undocumented behavior.

You could go back to using the earlier version-date, but I would like to recommend another approach. The context field of the message request body does support additional properties -- and this is officially documented and supported. So if you put the message_id directly in the context (not in context.metadata), it will be returned in the context of the message response.

mkistler avatar Jul 18 '19 21:07 mkistler

@aliuspetraska Does the above solution work for you?

dpopp07 avatar Jul 29 '19 17:07 dpopp07

Closing as this can be addressed on user side

dpopp07 avatar Aug 01 '19 22:08 dpopp07