Skip to content

Instantly share code, notes, and snippets.

@adamjuhasz
Last active April 2, 2017 15:47
Show Gist options
  • Save adamjuhasz/dc29a89835204cacbc972afa9363f065 to your computer and use it in GitHub Desktop.
Save adamjuhasz/dc29a89835204cacbc972afa9363f065 to your computer and use it in GitHub Desktop.
alana timeout responses
.dialog(function(session, response, stop) {
// always send typing indicators
response.sendTyping();
// make an api request
request({ uri: '', method: 'POST' ... })
.then(function (results) {
response.sendText(`The weather will be ${results} today`);
})
.timeout(5000) // timeout is in ms
.catch(Promise.TimeoutError, function(e) {
// if the request returns in less than 5 seconds, timeout(...) won't be callled
response.sendText('Still working on your qustion, give me a few more seconds');
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment