This tutorial is structured as a lab and is produced for Public Media Potluck's Alexa skill building session.
At the end of this tutorial, you will have a quiz skill that you can customize with your own content.
It may be helpful to keep these references open in separate tabs while going through this tutorial.
These files don't exist yet, but we will create them in the next steps. Starting from the skill directory, here are some files to take note of:
./skill.jsonWhere you can modify the skill name, description, and example phrases../models/*.jsonFor this example, we're usingen-US.json. This is where you can change the invocation name, intents, and sample phrases to invoke the intents../lambda/custom/index.jsThe meat of the skill. Where you can edit quiz questions and answers.
-
Start a new project with
ask newand name the skill. This will create a few new directories for the skill. -
Change directories into your newly created skill directory. Install tne npm dependencies in
/lambda/custom:$ cd lambda/custom $ npm install -
Go back to your skill's root directory:
cd .. -
Open
./models/en-US.jsonfile and change the invocation name fromhello worldto something of your choosing. For example,potluck quiz -
Deploy the app:
ask deployMake note of the Skill Id that is created. You can also see the skill id through the Alexa developer console.
-
copy and paste the skill id into
index.jshere:var alexa = Alexa.handler(event, context); alexa.appId = "SKILL_ID_HERE"; -
Enable the app through that Alexa developer console.
-
Simulate talking to the skill:
$ ask simulate -l en-US -t "tell potluck quiz hello"You should get a JSON response back with
"status": "SUCCESSFUL"in the body. -
You can also test out your skill using the Alexa developer console and clicking through to Test > Go to Test Simulator.
-
Customize the skill invocation, description, and sample phrases.
-
Change the greeting to something customized.
-
Create an intent to ask a quiz question.
-
Add an intent to get the user's answer.
- tricky part is custom intent schema
- if it's not the last question, we need a way to get to the next question
-
Add a way to show a score.
response.speak('Hello World')builds the response but doesn't emit anything.emit(':responseReady')emits the response that was already built.emitWithState("TargetHandlerName")transfers one state handler to another and fires that event.