Skip to content

Instantly share code, notes, and snippets.

@mduleone
Last active April 11, 2016 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mduleone/caede5f4dddb2b62649441e77c6931d6 to your computer and use it in GitHub Desktop.
Save mduleone/caede5f4dddb2b62649441e77c6931d6 to your computer and use it in GitHub Desktop.
function intentHandler (session, other, stuff, callback) {
// some random stuff...
request.post({options: "duh",}, {body: "duh",}, function (e0, r0, b0) {
// Now you know that post has returned, do the get stuff you needed
request.get({otherOptions: "duh",}, function (e1, r1, b1) {
// Now you know that get has returned, do the stuff you need.
callback(
sessionAttributes,
buildSpeechletResponseCard(
cardTitle,
speechOutput,
cardOutput,
repromptText,
shouldEndSession
)
);
});
});
}
makePost(callback) {
request.post(options, body, function(e, r, b) {
callback(e, r, b);
});
}
function intentHandlerWithPost (session, other, stuff, callback) {
makePost(function(e, r, b) {
// Now you know that post has returned, do the get stuff you needed
request.get({otherOptions: "duh",}, function (e1, r1, b1) {
// Now you know that get has returned, do the stuff you need.
callback(
sessionAttributes,
buildSpeechletResponseCard(
cardTitle,
speechOutput,
cardOutput,
repromptText,
shouldEndSession
)
);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment