Epistemic Noise
Alexa Skills with PythonAlexa Skills with Python · Part 1 of 5

Alexa Skills with Python : An Introduction

An Introduction to Alexa Skills

Develop Alexa Skills with Python Part 1: The key concepts of Alexa Skills.

Photo by Brandon Romanchuk on Unsplash

Hello friend!

We have a long way to go. This is the pilot for a series on everything you need to know about Alexa skills, so let’s just pretend we’ve done an introduction on how voice will be shaping our future, how it will revolutionize the interaction between humans and machines, and how much leverage you will gain if you know how to build these technologies. Let’s just pretend we’ve already done that and get straight to the point.

Also, since we agreed not to spend much time in theory, I’ll give you the most simplified explanation of what an Alexa skill is.

You know what a smartphone is, right? (please say yes because I can’t continue otherwise 😅). You also know that, although they come with some built-in applications (calculator, calendar, camera, etc.), what makes smartphones powerful is the fact that we can develop and install lots of other apps (Facebook, Reddit, Gmail, Slack, Netflix, etc.). Great! So remember this analogy: Alexa device is like your smartphone, while Alexa skills are the applications you run on top of it.

This way, you can understand that when it comes to what you can develop for Alexa, the sky is the limit. You can develop pretty much whatever idea you have in mind. And this series will give you the tools to do that.

Photo by Lazar Gugleta on Unsplash

What We will Learn

As I said, this post is the first in a series of (at least) 5 tutorials that I’m going to use to walk you through everything you should know to turn any idea you have in mind into an Alexa Skill. (Okay, “any” is not the right word to use here, but you get the idea 😉).

In this first article, we are just explaining the key concepts of an Alexa skill, we won’t be coding anything. In the next post, we will create a basic skill that will accompany us throughout our 5-posts journey. I chose a case study that will allow us to add (and therefore learn about) the main functionalities every Alexa skills developer should be aware of.

The third post is about adding Alexa Presentation Language (APL) to our skills. In other words, we will provide a visual experience to Alexa devices that have screens. Next, we will discover how to implement a multi-language skill in the fourth post, that is to have our skill speak different languages depending on where our users are. Finally, the last tutorial will cover the monetization techniques, or put it another way, it is a tutorial on how to earn money through your skill 💰.

Rock Paper Scissors

Image by mathgun from Pixabay

Rock paper scissors is a hand game, usually played between two people, in which each player simultaneously forms one of three shapes with an outstretched hand. These shapes are “rock” (a closed fist), “paper” (a flat hand), and “scissors” (a fist with the index finger and middle finger extended, forming a V). [Wikipedia]

I chose this game for our case study for two reasons: first, because (almost) everyone knows what it is. Second, because of its simplicity. And by simplicity, I mean that we won’t worry so much about the logic of the game as we will about learning the Alexa tools. So yeah, SPOILER ALERT 🚨🚨🚨🚨, we will develop a Rock Paper Scissors skill.

Alexa Skills: General Concept

To develop an Alexa skill you need to have a free Amazon Developer account. That’s it. Nothing else. With that account, you get access to a developer console where you can use the Alexa Skills Kit (ASK) framework to create Alexa skills.

The following figure shows how end-users interact with a skill. They invoke the skill by saying, for instance: Alexa, open Rock Paper Scissors. The device streams the speech to the Alexa service in the cloud, where some Deep Learning magic is performed to determine what is the intention of the user.

This intention (or intent) is what the Alexa service sends to your backend (Yes, I know... Sometimes it’s not just the intent, but also some other variables, but we’re simplifying here! so let me finish 😡)

Image from Alexa documentation

THEREFORE, developing a skill means two things:

  • Helping the Alexa service to detect the intention of the user;
  • Figuring out what we will do after knowing this intention (backend logic).

Indeed, the Alexa service handles the speech recognition and natural language processing stuff, thus our work as developers is limited to creating these intents and giving some samples to train the model. [More info]

Few Words about ASK

The Alexa Skills Kit is a software development framework, it includes APIs, libraries, tools, code samples, and training materials. Its main purpose is to make it easier for us to create Alexa skills.

Mr. Robot Happy Bday Fábio from memegenerator

I’m not going through everything ASK provides, but it’s worth noting that this wonderful framework makes our lives as developers much much easier. It gives us access to the Alexa Developer Console, SDKs (Python, Java, and Node.js), testing tools, a straightforward certification process, and Design techniques, to name a few.

One (?) More Thing

Before wrapping up, let me just add these three notes:

  • The vast majority of tutorials and codes I found on popular platforms (GitHub, Stack Overflow, Medium, etc.) used Node.js and being a Python guy, I had a hard time finding the right Python answers to my specific needs. I hope you’ll find this series useful if you’re trying to develop Alexa skills using THE BEST programming language in the Universe: Python.

Image from meme-arsenal

  • After you create your skill, you can use it privately for your Alexa devices. Besides, you can publish it to the Amazon Alexa Skills Store so that anyone owning an Alexa device could enable it. (Remember the analogy we did earlier between Alexa and smartphones, here the Skills Store is the equivalent of App Store or Play Store). Naturally, you have to get your skill certified by Amazon first, but the certification process is as easy as falling off a log 😉.
  • The code samples used in this tutorial are available on my GitHub profile.

Ok, no more theory. Let’s just move to the next post where we’ll start talking Python 😎.

Image from memecreator

Alexa Skills with Python : An Introduction