Writing an Alexa Skill — Part 1

Andrew
3 min readAug 29, 2020

In my earlier post, I wrote about a couple Alexa skills I created to tell me when to take the garbage out. In this post I am going to write about the process of writing those skills.

Getting Started

I had used a few skills on my Echo and interacted with them in the Alexa app, but I had no idea how to write one. In the app there was a place to create skills based on some pre-defined “Blueprints”. I briefly looked into this but decided it was too simplistic for my needs.

Naturally, I turned to AWS next to see how to write skills there — and while you could write the core logic of skills as Lambda functions on AWS, you will still need to develop the skill’s frontend (the voice interaction model) in Amazon’s Alexa Developer Console. As it turns out, for skills that are not too complex and don’t expect a lot of traffic, you can actually develop (and host) the entire skill — frontend and backend — directly in the console using its set of online development tools. The whole experience is fairly streamlined and this is the route I ended up taking (AWS will come in handy later on tho).

Getting access to the developer console was straightforward; I was able to sign in using my existing Amazon shopping account and just enable and agree to a few things, as I recall.

The console provides a rich set of tools taking you through the entire development cycle of a skill: from initial creation, to writing the code, to testing and eventual publishing. In particular, if you use the Alexa hosted skill option — the one I picked — you’ll be provided with free hosting of your code with a number of features:

  • AWS Lambda endpoints in all three Alexa service regions
  • An Amazon S3 bucket for media storage
  • An Amazon S3-backed key-value table for managing session persistence
  • An AWS CodeCommit repository

The first version of my skill was fairly simple. The garbage pickup in my municipality happens on odd-numbered weeks or even-numbered weeks, depending on the location of your address. For example, if you live in a zone designated as a blue zone, then your garbage is picked up on the 1st, 3rd, and 5th-week of the year, and so on. Vice-versa if you live in a yellow zone.

For any given week, it is therefore easy to determine if it is a “blue week” (odd), or a “yellow week” (even). However, what I do not know is where the user of the skill lives (perhaps there are ways to determine this from the user’s profile, but I did not look into it). So, when the user asks my skill whether “is it garbage week”, my skill can only give back generic responses such as:

“It is garbage pickup week if you live in a blue zone” or

“Week 28 is a yellow week”

Still, I was happy enough with getting this far for a first version and submitted my skill for certification and published it to the skill store.

That’s it for this post. For my next post on this topic, I will outline what I did to improve the skill so that it can respond with a more tailored answer.

Updates:

--

--