Skip to Content
Learn
Use Dialog Management in Lambda
Delegate Directive

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.

Instructions

1.

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:

this.event.request.dialogState
Folder Icon

Take this course for free

Already have an account?