I´m playing with the Alexa API. I want to have Alexa respond with content received from a service.
not sure where to add the promise. I tried with this but Alexa is saying "There was a problem with the requested skill's response"
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntent';
},
handle(handlerInput) {
MyService.facts().then(function(data) {
const speechText = 'No facts';
if (data) {
speechText = 'random facts: '
data.forEach(function (fact) {
speechText += fact;
})
}
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
}, function(err) {
console.log(err);
});
}
};