I'm returning a response from Nodejs Lambda function and is giving a blank response like this :
{
"version": "1.0",
"sessionAttributes": {
"outputSpeech": {
"type": "PlainText",
"text": "Welcome to Alexa Skill"
},
"shouldEndSession": true
},
"response": {}
}
The session attribute should be blank and response should contain the content of the session attribute but it is happening exactly reverse. Here is the code to generate the response.
context.succeed(
buildResponse(
buildSpeechletResponse("Welcome to Alexa Skill", true),
{}
)
)
and these are the helper functions:
function buildSpeechletResponse(outputText, shouldEndSession) {
return {
outputSpeech: {
type: "PlainText",
text: outputText
},
// card: {
// type: "Simple",
// title: title,
// content: output
// },
// reprompt: {
// outputSpeech: {
// type: "PlainText",
// text: repromptText
// }
// },
shouldEndSession: shouldEndSession
};
}
function buildResponse(sessionAttributes, speechletResponse) {
return {
version: "1.0",
sessionAttributes: sessionAttributes,
response: speechletResponse
};
Just watch the argument order in buildResponse helper method. You are passing it in reverse. Just change as follows.
context.succeed(
buildResponse({},
buildSpeechletResponse("Welcome to Alexa Skill", true)
)
)