Hello
I have a problem with the SessionEndedRequest - it actually is not working at all. Whenever the user says exit I get the following Alexa error: "There was a problem with the requested skill's response".
I am using the basic code from any SDK2 example and haven't changed a thing. In other skills this is working, but here it throws an error. This is the code:
const SessionEndedRequestHandler = { canHandle(handlerInput) { const request = handlerInput.requestEnvelope.request; return request.type === 'SessionEndedRequest'; }, handle(handlerInput) { const { requestEnvelope } = handlerInput; const request = requestEnvelope.request; console.log(`Session ended with reason: ${request.reason}: ${request.error.type}, ${request.error.message}`); console.log(`Session ended with reason: ${handlerInput.requestEnvelope.request.reason}`); return handlerInput.responseBuilder .withShouldEndSession(true) .getResponse(); }, };
The JSON input says:
"request": { "type": "SessionEndedRequest", "requestId": "amzn1.echo-api.request.02d0fba2-babf-4ec8-8774-84d9e1e604a9", "timestamp": "2018-11-22T14:01:11Z", "locale": "en-US", "reason": "USER_INITIATED" }
The JSON output says:
null
In CloudWatch the error is:
2018-11-22T13:53:53.198Z 0c132d53-ee5e-11e8-a8c9-096dbaf7d85a{ "errorMessage": "Cannot read property 'name' of undefined", "errorType": "TypeError", "stackTrace": [ "Object.canHandle (/var/task/index.js:266:54)", "DefaultRequestMapper.<anonymous> (/var/task/node_modules/ask-sdk-core/lib/dispatcher/request/mapper/DefaultRequestMapper.js:74:61)", "step (/var/task/node_modules/ask-sdk-core/lib/dispatcher/request/mapper/DefaultRequestMapper.js:44:23)", "Object.next (/var/task/node_modules/ask-sdk-core/lib/dispatcher/request/mapper/DefaultRequestMapper.js:25:53)", "fulfilled (/var/task/node_modules/ask-sdk-core/lib/dispatcher/request/mapper/DefaultRequestMapper.js:16:58)", "<anonymous>" ] }
I have no idea what's going on here.
Thanks for reading so far. I know this might all just be basic, but I am still learning.
Rene