0
votes

While testing my skill, if I do not reply and it times out, Alexa sends a SessionEndedRequest to my Lambda function.

Based on these docs: Handle Requests Sent by Alexa:

Your service cannot send back a response to a SessionEndedRequest.

Therefore, I am not responding to these requests.

But then my app shows a card with this message:

Skill response was marked as failure
(Skill Name)

Request Identifier: amzn1.echo-api.request.xxxxxxxxxxxxxxxxxxxxx

The target Lambda application returned a failure response

So what should we handle this request that does not give a response, and does not result in this error?

I use Node.js in Lambda, but a Python answer is fine too.

1

1 Answers

1
votes

Are you sure the error in the card was for SessionEndedRequest only?

Generally, even if you send a response back to Alexa for a SessionEndedRequest, it won't be spoken.

You can handle a SessionEndedRequest like this in ask-nodejs-sdk-v2.

const SessionEndedRequestHandler = {
  canHandle(handlerInput) {
    console.log("Inside SessionEndedRequestHandler");
    return handlerInput.requestEnvelope.request.type === 'SessionEndedRequest';
  },
  handle(handlerInput) {
    console.log(`Session ended with reason: ${JSON.stringify(handlerInput.requestEnvelope)}`);
    return handlerInput.responseBuilder.getResponse();
  },
};