i'm using the open weather map api in order to get information on the current weather and then integrate it with watson assistant (i used this as a reference for the watson assistant code) before deploying on the terminal. here's my code:
var city = "Seattle";
weather.setCity(city);
function processResponse(err, response){
if(err){
console.log(err);
return;
}
var endConversation = false;
if(response.intents[0]){
if(response.intents[0].intent=="CurrentWeather"){
weather.getDescription(function(err, desc){
weather.getTemperature(function(err, temp){
console.log("It is " + desc + " today with a temperature of " + temp + " degrees Celsius.");
)};
)};
}
else if(response.intents[0].intent=="end_conversation"){
console.log(response.output.text);
endConversation = true;
}
}
if(!endConversation){
var newMessageFromUser = prompt(">> ");
service.message({
workspace_id: workspace_id,
input: {
text: newMessageFromUser
},
context: response.context
},processResponse);
}
}
it works, but then the response looks like this:
>> what is the weather today in seattle
>>
It is few clouds today with a temperature of 29 degrees Celsius.
>> bye
['See ya!']
whenever i use any third party apis, instead of responding right after i enter the trigger keywords, the terminal asks me to input another entry (in the scenario above, i entered nothing) before responding. however, when i try to enter keywords related to intents whose responses are just retrieved right away from the watson assistant (as is with end_conversation), the terminal responds right away.
Is there a way for me to force the terminal to only ask once?