Sayuri Mizuguchi Sayuri Mizuguchi -4 years ago 136
Javascript Question

How to extract information entered by the user into Watson conversation?

I need to save the information that the user types into a variable, how do I do this?
I've placed context variables with "input.text" and need to use this information in my application to get all user type...

I put in the context variables: "data1, data2, data3, context variables with "input.text" to get the user type and I need this information for use in my webapp.

My example JS:

var varDatas = context.data1, context.data2, context.data3;
function OneFunction(xxxxxxxxx, xxxxxxxxxxx){
type: 'POST',
dataType: 'json',
contentType: "application/json",
url: 'http://xxxxxxxxxxxxxxxxxxxxxxxx/request/create',
data: JSON.stringify({
"description":varDatas, // data type from user here

success:function(output) {
error:function(output) {
return '0';

Answer Source

To be honest I am not sure what you are trying to achieve. If you are after the input text that a user types i.e. a question, its the responsibility of the application to capture this text with in the application and then pass this text on to the Watson Conversation service, which then responds. At this point there is nothing stopping you from storing this input text into a variable within your application.
If you wish the Watson conversation service to extract 'entities' from within the input text, and then store these entities within a variable, this has been well documented both with the Watson doc's and within this forum.
If you wish to store the input text as part of the context element of the conversation json packet, you could do this as part of the input call to the WCS, or as part of the output. I would create a context variable like context.input_text = question { = input.text }.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download