2
目前,我正在开发一些聊天机器人,并且我想知道如何通过超时等方式完成对话。chatbot的超时Watson Conversation Service
实施例I:
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)
}
实施例II:
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
}
实施例III:
//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
变量。
基数:对话简单。
如何解决这个问题?
感谢提前。
是的,谢谢。但是我需要知道如何在代码中做到这一点,在这两种情况下,在这种情况下,data.context中的值或我不知道,我可以用来验证用户是否输入任何内容。我需要代码示例来完成对话。 –