3 Steps to Your Own Amazon Alexa Skill (Tutorial)
So, my awesome kids gave me an Amazon Echo Dot for Christmas. I love it! Echo has so many fantastic built-in skills and an entire marketplace of third party skills. One of my favorite third party skills is the Plex skill. “Alexa, ask Plex to play Blade Runner.” The one skill the world really needs is a “Dad Jokes” skill. Don’t you think? 😁 I thought so. I did a little Googling, failed a bunch of times, and then finally got my Dad Jokes skill working. To save you the Googling and the failing, here are some steps that work. The most useful guide I found is here. Thankfully, the lessons I learned creating a Microsoft chat bot in this post applied well to creating this Alexa chat bot.
Step 1: Create a New Alexa Skill
Login to the Amazon Developer Console
Click Alexa
Click Get Started under Alex Skills Kit
Click Add a New Skill
Name your skill and provide an Invocation Name. If you would like to read about the three types of skill types, you can find that information here. Click Next.
Paste this text in for the Intent Scheme
{
“intents”: [
{
“intent”: “TestIntent”
}
]
}
Type in a few Ample Utterances, or just paste this text
TestIntent Tell me a Dad Joke
TestIntent Tell me another
TestIntent Tell me another Dad joke
TestIntent Tell me a joke
Click Next
Step 2: Create a New AWS Lambda Function to Process the Skill
Choose AWS Lambda ARN & North America on this page. We will come back to this page once we have created our Lambda function that this page is looking for.
We’ll hop over to the AWS Console to create our Lambda function.
Click Lambda
Click Create a Lambda function
We will Edit code inline and paste the sample code from my favorite tutorial here.
Line 103-104 defines what the Amazon Alexa | Echo will say when the skill is invoked. The sample code says one thing “Hello, World!” I replaced this thine with a switch statement driven by a random number. This was the custom code I came up with to replace this line
var phrase;
switch (Math.floor(Math.random() * (9 – 0 + 1)) + 0) {
case 0:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Which side of a chicken has the most feathers? The outside”, “”, “true”));
break;
case 1:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Dad, make me a sandwich. Poof, you’re a sandwich.”, “”, “true”));
break;
case 2:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“What’s brown and sticly? A stick.”, “”, “true”));
break;
case 3:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Did you hear about the guy who fell in the upholstery machine? Don’t worry, he’s fully recovered.”, “”, “true”));
break;
case 4:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Did you hear about the guy who had his entire left side cut off? He’s alright now.”, “”, “true”));
break;
case 5:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Why hasn’t Abraham Lincoln ever been charged with a crime? He’s in a cent.”, “”, “true”));
break;
case 6:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“To the guy that invented the zero. Thanks for nothing.”, “”, “true”));
break;
case 7:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“When is it time to go to the Dentist? Tooth hurty.”, “”, “true”));
break;
case 8:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“What does and octegenarian say on his birthday? Aye matey!”, “”, “true”));
break;
case 9:
callback(session.attributes,
buildSpeechletResponseWithoutCard(“Did you hear about the kidnapping at the school? It’s OK, he woke up.”, “”, “true”));
break;
}
Below the code window, choose lambda_basic_execution for Existing role*. Click Next.
Review the Lambda function summary screen and click Create function.
After you have finished enjoying the Congratulations, copy the ARN URL in the upper right. You will need that for your skill.
Switch back to the skill page, we left earlier and paste in the ARN URL.
Click Next