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 
} 

,谈话瓦特病毒消息发送给用户后完成。 但我需要一些方法来确保用户是否输入任何内容。我想要保存这个布尔值truefalse里面的userInputText变量。

基数:对话简单。

如何解决这个问题?

感谢提前。

回答

1

例1你几乎已经知道了。如果应用程序从对话服务中收回错误,则只显示一些预先写好的文本。

对于超时,您的应用程序必须控制计时器。你可以把它作为背景发送给对话并以这种方式作出回应,但我不知道你为什么要这样做?我想在你的应用程序中,你有一个计时器,如果没有响应,然后给他们一个主动的消息“你还在吗?”或类似的东西,但林不知道为什么你想结束这样的基于时间的对话。

+0

是的,谢谢。但是我需要知道如何在代码中做到这一点,在这两种情况下,在这种情况下,data.context中的值或我不知道,我可以用来验证用户是否输入任何内容。我需要代码示例来完成对话。 –

相关问题