Skip to Content
Understand Your Lambda Function
Add canHandle for LaunchRequest

We can request a response from our skill in two ways:

Style 1: “Alexa, tell {YOUR-FIRST-NAME} {LAST-INITIAL}’s code academy hello”


Style 2: “Alexa, open {YOUR-FIRST-NAME} {LAST-INITIAL}’s code academy”

Style 1: IntentRequest

When the user says “Alexa, tell {YOUR-FIRST-NAME} {LAST-INITIAL}’s code academy hello”, Alexa recognizes that a specific intent is being requested (IntentRequest), and using the sample utterances provided in the Interaction Model, maps it to HelloIntent. (You may have added these utterances in Build Your First Alexa Skill.)

You can see in the truncated JSON response below that our skill receives a request of type "IntentRequest", and name "HelloIntent".

{ "session": { ... ... }, "request": { "type": "IntentRequest", "intent": { "name": "HelloIntent", "slots": {} }, ... }, ... }

Style 2: LaunchRequest

If however, the user invokes the skill with the invocation name, but does not provide any command mapping to an intent, like “Alexa, open {YOUR-FIRST-NAME} {LAST-INITIAL}’s code academy”, our skill will receive a “LaunchRequest”, instead of “IntentRequest”.

You can see in the truncated JSON response below that our skill receives that the type of request is "LaunchRequest".

{ "session": { ... ... } }, "request": { "type": "LaunchRequest", ... }, ... }

To provide a response for this type of request, we will add another handler called LaunchRequestHandler. Its canHandle method will return true if the request type is 'LaunchRequest'.

const LaunchRequestHandler = { /* canHandle and handle go here */ };



Below the HelloHandler, create another handler named LaunchRequestHandler.


In LaunchRequestHandler, define a canHandle method with one argument, handlerInput.


Fill in the method canHandle so that it returns true if


is 'LaunchRequest'.

Folder Icon

Take this course for free

Already have an account?