Reputation: 481
Stuck from day. Problem is like this.
var alexa = require('alexa-app');
// Define an alexa-app
var myapp = new alexa.app('myapp');
myapp.intent('WelcomeIntent', function(request,response) {
console.log(request);
response.say("This is not working.<break time='2s'/>")
setTimeout(function(){
response.say("This is inside timeout.")
},1000);
});
On the Speech Simulator Amazon Alexa the output look like this.
{
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak>This is not working.<break time='2s'/></speak>"
},
"shouldEndSession": false
},
"sessionAttributes": {}
}
Please help me out. Problem is the response inside the asynchronous function like Promise or setTimeout or fetch or google map API I am not getting the proper response.
Upvotes: 0
Views: 451
Reputation: 481
So finally I figure out the solution.
To handle async callback in the alexa-app framework there are two way.
var alexa = require('alexa-app');
// Define an alexa-app
var myapp = new alexa.app('myapp');
myapp.intent('WelcomeIntent', function(request,response) {
console.log(request);
makePromiseBasedCallback(request,response);
return false;
});
makePromiseBasedCallback.then(function(data){
response.say(data.cardContent);
response.send();
});
follow the github link
Upvotes: 1