I'm creating sample application using Watson conversation API in nodejs. I'm trying to get username and send them to Watson and then I want to say hello "$username", also I want to keep that throughout the conversation so that I can if the user ask if I remember the name, Watson can say "yes, "$username"".
Can someone help me with sample code, how to use intent in this use case.
// Start conversation with Hello message.
conversation.message({
input: { text: "Hello" },
}, processResponse);
// Process the conversation response.
function processResponse(err, response) {
if (err) {
console.error(err); // something went wrong
return;
}
// If an intent was detected, log it out to the console.
if (response.intents.length > 0) {
//console.log('Detected intent: #' + response.intents[0].intent);
console.log(response.context)
}
// Display the output from dialog, if any.
if (response.output.text.length != 0) {
console.log("Watson : "+response.output.text[0]);
}
// Prompt for the next round of input.
var newMessageFromUser = prompt('Me : ');
// Send back the context to maintain state.
conversation.message({
input: { text: newMessageFromUser },
context : response.context,
}, processResponse)
}