i know if I want send any to Watson in conversation I use the:
var latestResponse = Api.getResponsePayload();
var context = latestResponse.context;
Api.sendRequest("Hi Watson!", context);
This result of my code:
I want to know how do I get Watson to send something in the conversation. I saw some examples and tried and it did not work. Can someone help?
I dont now If I'm doing right, but My example is:
// var responseText = null;
//responseText = {};
var latestResponse = Api.setResponsePayload(); // I dont know if this is true
var context = latestResponse.context;
Api.sendRequest('Hi ' + context); // I try this
responseText = 'Hi ' + context; // I try this too
This is what i want:
Did you check the demo app at https://github.com/watson-developer-cloud/conversation-simple ?
You can add objects to the context in a JSON way.
And send this with the input to the service
The other way around, inside the conversation service, you can assign a variable (in this case username) to the text provided in the previous step (in this case input.text). By using
$variablename
(in this case$username
) you can generate a dynamic response. Don't let the order in the advance response screen disturb you, context is processed before output...In the client (in my case Java)
This textObject will contain: Hi Joe, nice to meet you. I am here to answer questions about....
(Node.) JS code copied (and removed some lines ) from the sample app