...

/

Hero Trivia: Coding GetTriviaIntentHandler

Hero Trivia: Coding GetTriviaIntentHandler

We will code the handler for GetTriviaIntent in this lesson.

The user can ask Alexa for trivia related to heroes, and our Skill must be able to respond with that.

To achieve this, we are going to build a new handler. This handler will acknowledge that the user is asking for hero trivia and will give the trivia back to the user.

We’ll again follow the instructions step by step to complete the code and later copy it over to the Alexa console.

About HelloWorldIntentHandler

Notice that the HelloWorldIntentHandler is still in the code. Didn’t we delete HelloWorldIntent though?

Not entirely. While the intent is gone from the interaction model, the back-end handler is still present. We need a new handler, so let’s make things easier and reuse this handler for a new one called GetTriviaIntentHandler.

The handler for HelloWorldIntent still exists in the code.
The handler for HelloWorldIntent still exists in the code.

Create GetTriviaIntentHandler

It’s time to replace HelloWorldIntentHandler with GetTriviaIntentHandler.

  • Find the line that starts with const HelloWorldIntentHandler. On that line, rename HelloWorldIntentHandler to GetTriviaIntentHandler. We have done this for you in the code widget below.
  • Within the GetTriviaIntentHandler on the line that begins with && Alexa.getIntentName, change
...