Last active
April 2, 2017 15:47
-
-
Save adamjuhasz/dc29a89835204cacbc972afa9363f065 to your computer and use it in GitHub Desktop.
alana timeout responses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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