I’ve been developing onto of Amazon Alexa for a few months now, and find the platform a lot of fun to use, and the possibilities pretty endless. Alexa is still fairly new, which offers its own challenges, however being one of the first developers to build and publish skills to the library is pretty awesome.
I just recently launched the latest skill under BrownDog Tech to the skill library. Math Dog is a quiz game style skill where the user is asked a set of math problems. As the user answers more questions correctly, the difficulty rises and the questions get more difficult. Though anyone can have fun with Math Dog, it was really designed for young students learning their basic math facts, with my own son Alex in mind. In fact, he has been my beta tester from the first versions of Math Dog.
Test out Math Dog!
If you are signed into Alexa already, this link should take you to where you can enable the skill on your devices. Please give Math Dog a try. Alex and I are looking forward to checking out all the reviews and adding new features.
I’m trying something a little different for this post. Rather than simply type up a long blog post with all the details, I’ve recorded a series of video’s that walk through different aspects of Math Dog to go along with the blog post itself. I’ll give some highlights here, but definitely watch the videos for a more in-depth discussion.
Quick 2 Minutes on where the idea for Math Dog came from
Math Dog in Action
Alex takes Math Dog for a spin
Designing and Building Math Dog
Design Walk through showing how Math Dog was originally designed with a Voice User Interface (VUI), a look at the code that runs on AWS Lambda, and publishing to Amazon Developer Site
I highly recommend going through the design video above for a more thorough look at how Math Dog was pulled together, but here a few highlights as well.
Voice User Interface (VUI) Design
At the heart of every Alexa Skill is the Voice User Interface, or VUI. Users of Alexa don’t point and click on a GUI, but rather interact by talking to your application. Having a solid plan about how users will start and end your application, how they will get help if confused, and how they will actually use your application is important before you dive into writing any code. So Math Dog was first born as a VUI diagram shown below.
Creating VUIs is still a pretty new part of software design, and I didn’t find any good references on what was considered “best practice”, so being fairly creative and skilled in building understandable and nice looking diagrams, I took a swag and coming up with something that worked. I settled on identifying some key aspects of the design.
- Contextual Intents
- Voice Responses
- Decision Points
- Updating Application State
An “Intent” is a term for an Alexa skill entry point. It is an indication of the users “intent” to have the skill take some action. In Math Dog, intents include Start Game, Set Difficulty, and Get Help among others.
“Contextual Intents” is a term I completely invented to describe a case where the users intent can only be determined based on the context in which the statement was made. If a user says Yes, your program can only determine what to do if it knows what the response was in relation to.
Alexa is a conversation between your user and your application. The Voice Responses are your applications side of the conversation.
Some applications will be very linear, but most will require some logic to determine what to do next.
Updating Application State
Alexa is a stateless application by default. This means you need some method in your application to track users as they move through your skill.
The Code and Program
Python continues to be my go to language of choice, and Alexa provides great support for building in Python. There are several sample applications and tutorials available on developer.amazon.com/alexa, and I leveraged some of them to build the basis for my skill templates. All the code for Math Dog is available on GitHub, and I’ve done my best to include comments to explain how it work.
To actually run the code, I leverage AWS Lambda to host the functions and handle all the actual processing. Alexa supports developers hosting their own code and leveraging a REST interface to communicate, but Lambda removes many of the security and authorization requirements needed when you host your own that I’ll consider it a first option in all future skills.
Publishing a Skill to Alexa
Amazon makes the publishing process pretty simple and straightforward. Once you create an account on https://developer.amazon.com/alexa, you can easily build add a new skill in “Development Mode”. Once you feel it is ready to go through certification process, you simply click a button to submit it and wait. My experience has been it takes 3 – 4 days for the process to go through, and though my first two Skills did NOT pass certification the first time through, the feedback from the team was clear, and I was able to fix and resubmit very easily. Math Dog was my third time through the process, and I am happy to report that it passed on its first inspection.
I have plans for many updates to my existing skills for Alexa, as well as some new projects. And though Amazon has made it pretty straightforward to get started building skills, I’ve some ideas for a few “Getting Started Developing for Alexa” posts that I think would help speed folks along looking to jump in. If you think some posts along those lines would be helpful, leave a note in the comments. Until next time.