question

Pat avatar image
Pat asked

LaunchRequest throwing a name error

Having an issue with the LaunchRequest when starting the skill with no intent I get a generic error:

2021-12-13T14:27:57.925Z 60f31e0d-3eeb-4790-9bb9-7c4a6dde7632 INFO Error handled: TypeError: Cannot read property 'name' of undefined


There are three interceptors which load and run with no errors.

When I start the skill with the a request for help the code runs as expected.

const HelpIntentHandler = {

canHandle(handlerInput) {

return handlerInput.requestEnvelope.request.type === 'LaunchRequest' ||

(handlerInput.requestEnvelope.request.type === 'IntentRequest'

&& handlerInput.requestEnvelope.request.intent.name === 'AMAZON.HelpIntent')

},

handle(handlerInput) {

console.log("Launch");

const speechText = handlerInput.t('HELP_MSG', {URL: resources.Church.URL_SPOKEN});


return handlerInput.responseBuilder

.speak(speechText)

.reprompt(handlerInput.t('HELP_PROMPT_MSG'))

.getResponse();

},

};

launch-word
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Andy Whitworth avatar image
Andy Whitworth answered

That code looks OK, sounds like one of your other canHandle() functions in other intent handlers has a bug and is attempting to access handlerInput.requestEnvelope.request.intent.name without checking if the request type is an IntentRequest. So when a LaunchRequest occurs then handlerInput.requestEnvelope.request.intent doesn't exist and attempting to reference "name" from it gives the error.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.