node.js - Alexa: Emit not working in chaining of function -
i trying ask question user , using amazon.yesintent
, nointent
capture response. in case response, calling other function should emit user. emit not being called. code below:
'use strict'; var alexa = require("alexa-sdk"); var https = require('https'); var alexa; exports.handler = function(event, context, callback) { alexa = alexa.handler(event, context); alexa.registerhandlers(handlers); alexa.execute(); }; var handlers = { 'launchrequest': function() { alexa.emit(':ask', 'my text'); }, 'oneshotintent': function() { var self = this; // removed code simplicity self.attributes['yes_no'] = true; alexa.emit(':ask', 'sample yes no question'); }) }, 'amazon.yesintent': function () { if (this.attributes['yes_no']) { delete this.attributes['yes_no']; alexa.emit('oneshotsecond'); } }, 'oneshotsecond': function() { delete this.attributes['yes_no']; // deleted // removed code simplicity var self = this; // removed code simplicity console.log(info); if (info) { console.log('here in if condition'); self.emit(':tell', 'sample text'); } else { self.emit(':tell', 'sorry failed'); } }); } };
the first emit working. console.log
in other function happening. emit failing.
no logs in cloudwatch also. ends after printing console.log
data points.
any help?
i not sure if understand
alexa.emit('oneshotsecond');
however have done below
oneshotsecond(this);
and
'oneshotsecond': function(self) { // use self.emit}
wiki
Comments
Post a Comment