Like a lot of other people, last Christmas I gave Alexa my heart. But the very next day... well, she didn't give it away. With a little integration, she blew me away.
Yes, I am a developer. And, I work with in a futuristic development environment. Since Alexa is also futuristic, it made sense to bring them together.
Let me tell you how this all went down.
Tinker, Tailor… Alexa?
I'm one of those developers who like to tinker with stuff. You can imagine the appeal an Amazon Echo Dot had for me. I knew I wanted one. So when this pretty little thing arrived on my doorstep, it was love at first sight.
I was eager to get my grubby little hands on my new toy. I knew I wanted to do some cool stuff with it, but I had no idea exactly what. In fact I didn’t know much about the Dot at all. So, I did the next logical thing.
I Laid Out a Quick and Simple Attack Plan
I decided I would start simple and so I:
- Did the initial setup. Setting it up was pretty simple and straightforward. Unless you're trying to set it up in an open WiFi network, that is. Just a little heads-up for you all. Other than that, I just installed the Alexa app: Android version here and iOS version right here. And then my new best friend held my hand and walked me through the rest of the configuration steps.
- Played some tunes. I have eclectic musical tastes. I listen to anything from pure, unadulterated classic heavy metal (Up the Irons!) all the way to the ever amazing K-Pop (MAMAMOO anyone?). The K-Pop is my brother's fault, by the way. (Smile and wave, Filipe. Smile and wave.) So, I chose to subscribe to Spotify and installed it.
- Bothered my friends. Yes, I went to most of them and asked what song they wanted to hear.
- Went crazy. Then I started going nuts. I set alarms, made to do lists, asked her the usual silly questions — like, "what is the meaning of life?” (We all know it's 42.0)
It was all fun and games. But, at the end of the day, was it really worth my time and money? If I really wanted to get the most out of my Dot, it was time to roll up my dev sleeves and get to work. I wanted to explore integrations.
Alexa, I Wanna Talk To You, So Tell Me: What Should I Do?
Alexa didn't have a proper reply. But then it dawned on me. We’re working on enhancing our digital operations at work. So, why not have Alexa report on things that were happening in our production server?
Whoa! I would finally have a personal assistant. The only caveat was that she needed some training.
Sifting Through Documentation
First things first. I had to embark on a delightful journey through the sinuous roads of... documentation. Developers love documentation. I'm not kidding, we do... right? Ahem.
Alexa's documentation is detailed and extensive. I quickly found out that Alexa has three types of integrations — her so-called skills:
- Smart Home: A skill that allows a user to control cloud-enabled smart home devices, such as lights and thermostats.
- Flash Briefing: A skill that provides original content for a customer's flash briefing.
- Custom: A particular set of skills that can handle just about any type of request.
Even though Flash Briefing seemed more or less ideal for what I wanted, I decided to go a little beyond. So, obviously, I chose the custom skills.
... I found out I needed two things:
- An input where I could paste a REST API URL.
- The respective Response/Request JSON sample.
Pretty simple, right?
After five looooong pages of "Understanding Custom Skills," I found out I first had to configure my new skill and only then could I set up the custom endpoint.
Teaching Alexa Some New Skills
Like every good student, Alexa needs some sample material first to understand how the real world works. This is done in three easy steps.
Step 1. Name Our Skill
This example tells it all.
Step 2. Enter the Fabulous World of Intents and Utterances
- Intents are actions that you want Alexa to recognize and are represented in a JSON schema.
- Utterances represent how you speak to Alexa, keeping the previously defined intents in mind.
I want Alexa to give me a report on errors and slowness, so this translates to:
- Intents — GetErrorReport and GetSlowReport
- Utterances — GetErrorReport to give me any error on my production server; GetSlowReport to give me the slow report.
If I say “Alexa, ask Blue to give me the slow report,” the skill will know that’s my intent and I’ll get a report on slowness in my endpoint.
Step 3. Set Up the Endpoint
How you set the REST API is pretty much up to you. I used the development platform my company created, which speeds up the process. This is nice because I wanted to get to the result as fast as possible. All while losing none of my dev cred. We all copy code, we all find ways to write less code, and my code is still very much a work of art — in a Picasso kind of way. It’s all about the logic. I just type, or copy and paste, a lot less.
Now For The Visuals
Since what I use is a visual language, I’ll just show you how it’s done.
In my next article! (Don't miss it!)
Here’s a teaser of what you’ll be getting, though:
In the meantime, if you have an Alexa story, I’d love to hear it. Drop me a comment or two.