Hero Trivia: Coding LaunchRequestHandler
We will code the intent handler for the LaunchRequestIntent.
In this lesson, we will get started with coding Hero Trivia step by step.
Try following the instructions and completing the code as instructed within the code section provided. You will receive feedback on any mistakes you might make at each step.
Once we are done coding and verifying that all tests pass, paste the code back into the “Code” section in the Alexa developer console and test things out.
Understanding the SDK
This is the structure that we will see throughout the back-end code:
const handler = {canHandle(handlerInput) {// Returns true if the handler can service the request},handle(handlerInput) {// Code to handle the request}}
First, we have what’s called a request handler. A custom Skill needs to respond to events sent by the Alexa voice service. For example, our back-end service receives a launch request or an intent request, it does something, and then sends a response. The code needs to handle these requests with different handlers. With the ASK SDK, we simply need to write a request handler.
The code needs to handle these ...