javascript - 聊天机器人 Watson Conversation Service 超时

标签 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 == 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 值 truefalse 保存它。

基础:简单对话。

如何解决这个问题?

提前致谢。

最佳答案

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

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

关于javascript - 聊天机器人 Watson Conversation Service 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43596215/

相关文章:

javascript - 在node.js 中使用express 链接jade 渲染

ibm-watson - 沃森对话 : How to maintain position in dialog flow for additional user input

python - IBM Bluemix Alchemy API key 无效

java - 如何将 IBM Watson Assistant 聊天机器人添加到网页上?

node.js - Firebase 数据库查询错误 : child is not a function

javascript - 在 Meteor React 客户端中显示所有用户

javascript - Gulp AssertionError - Sass 依赖项

javascript - 如何使用 Intern 在功能测试期间报告 JavaScript 错误?

javascript - 连续检查各个复选框

javascript - 内部 html 在 ie 中不起作用,但在 ff 中起作用