【发布时间】:2017-04-24 19:25:26
【问题描述】:
目前,我正在开发一些聊天机器人,我想知道如何通过超时之类的方式完成对话。
示例一:
if(callback.error){
data.output.text = "The server is offline now. Please try again later. Goodbye!";
return res.json(data); //send the message
exit(); //example (I did with sucess)
}
示例二:
if(userInputText == false && data.context.time === 120){
//time = seconds
data.output.text = "Are you still there?";
return res.json(data); //send the message
exit(); //example if user did not type anything
}
示例三:
//intent by user #goodBye
if(userSayGoodbye){
data.output.text = "Okay, goodbye!";
return res.json(data); //send the message
exit(); //EXAMPLE for exit the conversation if user say goodbye
}
在消息发送给用户后,对话将结束。
但我需要采取一些方法来确定用户是否没有输入任何内容。我想用布尔值true 或false 在userInputText 变量中保存它。
基础: 对话简单。
如何解决这个问题?
提前感谢。
【问题讨论】:
标签: javascript node.js ibm-watson watson-conversation