roundthecounty 2016

How to build an Alexa Skill without being an engineer (or the ambition to ever become one)

This is a step by step guide to how I built an Alexa Skill from scratch–and what I learned along the way. Skills are extending Alexa’s capabilities and are provided by 3rd parties, very similar to apps for the iPhone and android devices. After enabling the usual suspects of skills and services, think Nest, amazon music, Pandora, Lyft, I identified another use case that would address a question that comes up in our house all the time.

My partner, Leila, would often ask me “Can we go sailing tomorrow?” Typically, I would go the NOAA website, search for the desired location, check the wind and weather forecast and then tell her something like, “No, there is too much wind,” or “Yeah, wind looks good, let’s plan for it.” With the arrival of Alexa in our lives, Leila thought it would be cool, if Alexa could answer her question, so I decided to build a skill that would exactly do that: Wind Checker.

Coincidentally, I just finished a python class on codeacademy with the goal to play around with Tensorflow for getting a better understanding of the nuts and bolts of deep learning networks. I was quite happy when I learned that I could utilize my newly learned skills using a python based wrapper to develop the skill.

These are the activities that lead to publication of Wind Checker start to finish:

1) Review the Alexa Skills Kit (ASK)
I went to the Amazon developer website, read through most of the documentation and watched videos to understand the general architecture of skills and how intents and slots work.

2) Define the Skill
 I then determined what the skill is supposed to do and how it interacts with the user. This is crucial as voice interfaces are so different from web and app UI. Will it be conversational or more transactional? What if Alexa doesn’t receive all needed information or some of it is not correct or in the wrong format?

3) Start Building
 I learned the most while writing code and building simple interactions between Alexa and my first demo skills. I do have some prior coding experience and used a Unix based shell 20 years ago which helped me to set up my Mac for software development, though this is not a requirement for getting started with Alexa. None of the technologies and tools I’ve used are difficult to learn and there are plenty of instructions available on the Internet.
Here’s the list of tools I needed to install:

a. Pip. Packet manager needed for installing more tools.
b. Flask Ask. Python wrapper for ASK (Alexa Skills Kit).
c. Homebrew (optional). If you want to use python3.
d. Virtualenv. Creates virtual environments for each of your projects. Confusing at first but very valuable when deploying your final work.
e. Atom. My editor of choice.
f. Ngrok. Crucial for simplifying local development. Ngrok points ASK requests to your local machine using https.
g. PYOWM. Easy to use python wrapper for OpenWeatherMap API access. This is where I get the wind data from.
h. Zappa. Awesome tool to deploy your skill and related python modules to Amazon Lambda.

It’s okay to think, “What the heck are ngrok and zappa?” when reading through this list. I was surprised how fast one can become familiar with these tools and comfortable using them. Whenever I got stuck, I tried to break down the problem in smaller manageable parts and work through them one by one. This approach helped me make progress while learning the needed python syntax.

4) Focus on Development
 Flask ASK and the ASK (Alexa Skills Kit) are the areas that I spent most time on. The actual amount of python code itself is very small, which makes these projects doable in a short amount of time and without the need to fully understand all the details. Accessing weather data and making sense out of it took some time, as I needed to understand the API provided by OpenWeatherMap. Once I was able to configure a skill on the Alexa Dev Portal, and have it interact with my local python script using ngrok, I felt that I got the basic foundation done and could start to add more functionality piece by piece.

5) Prepare for Publishing and Certification
Before publishing the skill, make sure to do test the skill for potential error cases. In my case, I needed to catch missing data, invalid dates from the past or dates too far out in the future etc. Certification by amazon takes 2–3 days and is pretty straight forward. They test your example interactions and make sure skills are not infringing on somebody else’s trademarks. I hope amazon will improve publishers ability to modify skill descriptions and other metadata without the need to re-certify in the future. The marketplace is not on par with what iTunes and google play offer.

6) Watch and learn
63 Unique Users have activated the skill within the last 4 days. No reviews have been written yet but I’m hopeful to learn what my audience wants Wind Checker to become.

My intention for building the skill were based on curiosity of what it would take doing it and to create a fun way for Leila and others to check if wind conditions allow for going out on the water.

For the future, I have a list of features that I would like to add to Wind Checker:

- Users can specify time of day e.g. afternoon or 2pm
- Skill has access to NOAA marine weather including severe weather warnings
- Provide personalized recommendations based on sailing skills
- Wind Checker learns from user feedback to improve recommendations

I also believe there is room for 3rd parties to supply tools that add BI and a/b testing features to ASK. It seems that amazon has its hands full to add more core platform features like notifications and identity do Alexa right now and leaves space for other companies to fill in the blanks.

Voice will play a much larger role for accessing services and apps in the future and this is just the beginning. Amazon, Microsoft, Google, Apple and others are just getting started in building out their eco-systems and that’s the most exciting time to engage with Alexa & Co.

Please reach out to me or leave feedback, I’m happy to share more details but would also like to learn about your experience while developing skills for Alexa.

Happy coding (and sailing).