Reputation: 5330
Currently, I'm Development some chatbots, and I want to know how to finish the conversation with something like a timeout.
Example 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)
}
Example 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
}
Example 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
}
And the conversation will finish after the message will send to the user.
But I need to get some way to make sure if the user does not type anything. And I want save this with boolean value true
or false
inside userInputText
variable.
Base: conversation-simple.
How to solved this?
Thanks advance.
Upvotes: 2
Views: 905
Reputation: 849
Example 1 you've pretty much got it. If the app gets an error back from conversation service you just display some pre-written text.
for the timeout, your app has to control the timer. You could send it as context to conversation and respond that way, but im not sure why you want to do this? I would think in your app, you have a timer, if no response, then send them a proactive message "are you still there?" or something like that, but Im not sure why you want to end the conversation like that based on time.
Upvotes: 1