目前,我正在开发一些聊天机器人,我想知道如何在超时时结束对话。
示例一:
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
}
消息发送给用户后,对话结束。
但是我需要一些方法来确保用户是否没有输入任何内容。我想用 userInputText
变量中的 bool 值 true
或 false
保存它。
基础:简单对话。
如何解决这个问题?
提前致谢。
最佳答案
示例 1 您已经基本掌握了。如果应用程序从对话服务返回错误,您只需显示一些预先编写的文本。
对于超时,您的应用必须控制计时器。您可以将其作为对话的上下文发送并以这种方式回应,但我不确定您为什么要这样做?我想在您的应用程序中,您有一个计时器,如果没有响应,则向他们发送一条主动消息“您还在那里吗?”或类似的东西,但我不确定你为什么要根据时间结束这样的对话。
关于javascript - 聊天机器人 Watson Conversation Service 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43596215/