I'm trying to have my bot initiate a private conversation without hearing anything and ask a question. I also want to account for someone not replying and so allow the 'ask' to timeout and end the conversation rather than waiting forever.
I've got this up and running and it works fine but having left the question hanging for 15+ minutes it was still active and hadn't timed out. I've tried using a setTimeout function before the ask to stop the conversation after 5 minutes but (depending on what I asked it to do) this either didn't work or stopped the conversation's ask from even happening.
bot.startPrivateConversation({user: userId} ,function(err,convo) {
convo.ask('Can I say this?,[
{
pattern: bot.utterances.yes,
callback: function(response,convo) {
convo.say('Great! I will send it out');
// my function here
convo.next();
}
},
{
default: true,
pattern: bot.utterances.no,
callback: function(response,convo) {
convo.say('Maybe not then.');
convo.next();
}
}
]);
});
Is there a timeout on the conversation ask function and, if so, what am I missing? Is it something to do with the initial message that is normally created from a slack message? The timestamp-ts (which doesn't seem to be an actual timestamp) maybe?
If I understand you correctly, you're expecting your default to be triggered, when the conversation times out. I think you can accomplish what you're trying to do following this example.
You can react to a timeout in convo.on('end', ...), in that case status will be timeout.
Awesome.. I was fighting with that, I could not get the timeout yet, I'll mock an external service to do provoke that and run the convo.on(...) THANKS!
I know this issue is closed, but It didn't clarify anything to me.
If I start a conversation with a user, how do I explicitly set a timeout? When does the conversation timeout by default?
Use convo.task.timeout=900000 to set a timeout (in this case 15min)
This is wrong, it should be convo.task.timeLimit
What is the default timeout? @lucasgreene
Most helpful comment
I know this issue is closed, but It didn't clarify anything to me.
If I start a conversation with a user, how do I explicitly set a timeout? When does the conversation timeout by default?