As long as the dialogState is not 'COMPLETED', we want to delegate control back to Alexa, letting it handle slot collection for our skill. We can do that within our Lambda function by using the statement this.emit(':delegate').

This directive, or instruction, tells Alexa to continue handling slot collection using the prompts and utterances we provided in the developer console. Once all required slots/intents have been filled/confirmed, we can execute the main functionality of the intent — recommend a video!

Going back to our example conversation: dialogState is not 'COMPLETED' until the user has provided a slot value for videoType (movie vs. tv show) and genre (action, comedy, horror, drama). Until that happens, your function should delegate slot collection to Alexa. After that point all required slot values are collected and dialogState is 'COMPLETED'. Our Lambda function can then use the collected slot values to make a relevant video recommendation.



Currently, the intent handler FindVideoByGenreIntent looks up a video in the videos object. A comment marks the beginning and end of that main functionality. Let’s add some dialog management.

Finish the if-else statement in the intent handler:

  • If dialogState is not 'COMPLETED', delegate to Alexa using this.emit(':delegate').
  • Else run the main functionality of the intent already provided in the code.

Remember that dialogState can be accessed with:


Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?