0
votes

For 2 days now, I have the issue that my lambda function using the ask-sdk-core v2.0.2 returns invalid responses.

A very simple setup:

HelloIntent is handled by HelloIntentHandler:

const HelloIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'HelloIntent';
    },
    handle(handlerInput) {
        const speechText = 'Hello back';

        return handlerInput.responseBuilder
            .speak(speechText)
            .reprompt(speechText)
            .getResponse();
    }
};

When I call this intent, the simulator goes straight to:

There was a problem with the requested skill's response

Using the ErrorHandler, I checked and the results of handlerInput.requestEnvelope.request.error are:

{ type: 'INVALID_RESPONSE',
message: 'An exception occurred while dispatching the request to the skill.' }

Question: What is the problem here? When I open the skill using the invocation name, the LaunchRequestHandler gets called and responds properly, but any other intent does not work.

1

1 Answers

0
votes

Okay I found the problem, it is sort of difficult to deduct from the above error:

canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && handlerInput.requestEnvelope.request.intent.name === 'HelloIntent';
},

In the canHandle function, you need to check for the request type and intent name.