Javascript chatbot Watson对话服务超时

Javascript chatbot Watson对话服务超时,javascript,node.js,ibm-watson,watson-conversation,Javascript,Node.js,Ibm Watson,Watson Conversation,目前,我正在开发一些聊天机器人,我想知道如何通过超时之类的方式完成对话 示例一: 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 =

目前,我正在开发一些聊天机器人,我想知道如何通过超时之类的方式完成对话

示例一:

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
}
示例二:

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
}
示例三:

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
变量中保存它

基础:对话简单

如何解决这个问题


提前谢谢。

示例1您已经基本了解了。如果应用程序从对话服务返回错误,您只需显示一些预先编写的文本

对于超时,您的应用程序必须控制计时器。你们可以把它作为对话的上下文发送,并以这种方式回应,但我不知道你们为什么要这样做?我认为在你的应用程序中,你有一个计时器,如果没有响应,那么给他们发送一条主动消息“你还在吗?”或者类似的东西,但我不确定你为什么要根据时间结束这样的对话