1

I have this code in Node.js. I need to change the value of my context property in the response to IBM Watson Assistant, but this is not working:

if(response.context.email){
      response.context.email=null;
}

What is the form to change the value of context property?

data_henrik
  • 16,724
  • 2
  • 28
  • 49
Isaac Alejandro
  • 247
  • 1
  • 3
  • 8
  • Are you trying to change the value of "response.context.email" or "response.context" – joshbang Oct 18 '18 at 23:21
  • If you want to just delete the property off of response.context, you can do "delete response.context.email" – joshbang Oct 18 '18 at 23:24
  • How can I change the value from Node.JS? – Isaac Alejandro Oct 18 '18 at 23:29
  • The way you're doing it should be changing the value IF there is already an email property on response.context. Have you tried doing a console.log(response.context) to see if it is even going into the if statement? – joshbang Oct 18 '18 at 23:31
  • Yes, exist. In watson assistant I put the variable "email" like "true". I try to change the value to "null" but not working – Isaac Alejandro Oct 18 '18 at 23:33

1 Answers1

0

I would suggest to either use "null" as value or, better None.

You are on the client side. Only the values that you send to Watson Assistant are considered for further processing. If you change the reponse object (JSON object) to not contain any email property, it should not be available on the server side for Watson Assistant.

For manipulating the JSON object in Node.js you could look into using Object methods. This helps to delete or add properties to the response structure.

data_henrik
  • 16,724
  • 2
  • 28
  • 49