Setting up a Google Assistant App via the NodeJS Google Actions SDK is done this way:
It seems that these are synchronous functions (per the documentation given on https://developers.google.com/actions/reference/nodejs/ActionsSdkApp#ActionsSdkApp
const app = new App({request: req, response: res});
function pickOption (app) {
/*A bunch of steps here*/
}
function optionPicked (app) {
/*Another bunch of steps here*/
}
const actionMap = new Map();
actionMap.set(app.StandardIntents.TEXT, pickOption);
actionMap.set(app.StandardIntents.OPTION, optionPicked);
app.handleRequest(actionMap);
Is it possible for pickOption
and optionPicked
to be asynchronous functions? i.e., would it be correct to have pickOption
be implemented as
function pickOption(){
var pickOptionPromise = Q.defer();
pickOptionPromise.resolve({
/*Some results here*/
});
return pickOptionPromise.promise;
}