Hello,
I have a web application which is returning response as string. I have the following code
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
},
handle(handlerInput) {
var speakOutput;
request('http://8ccdee84.ngrok.io', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the body
speakOutput = body;
});
return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};
The 'body' of the request has the string data and i could see the string value get printed in the console log. However the speakOutput on .speak is empty and getting the following response.
{
"body": {
"version": "1.0",
"response": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak></speak>"
},
"reprompt": {
"outputSpeech": {
"type": "SSML",
"ssml": "<speak></speak>"
}
},
"shouldEndSession": false,
"type": "_DEFAULT_RESPONSE"
},
"sessionAttributes": {},
"userAgent": "ask-node/2.7.0 Node/v8.10.0"
}
}
Anyone help me what is the issue in the code and please explain me why i'm getting the string value in the console and not on the speak output.