Magic mirror, on the wall—who is the fairest one of all?
Probably the most memorable line from Disney’s 1937 classic, Snow White and the Seven Dwarfs, it may soon become a household phrase again. Modern-day magic mirrors are taking a number of forms, from toys to high tech devices offering useful information to their masters. Now, Darian Johnson has taken that concept an enormous step farther.
Darian, a technology architect with Accenture, has worked in software solution design for 17 years. Today he helps clients move their on-premise IT infrastructure into the cloud. With a recent focus solely on Amazon Web Services (AWS), it’s only natural other Amazon technologies like Alexa would pique his interest.
One night, Darian was pondering what he might build for Hackster’s 2016 Internet of Voice Challenge. He was surfing the web, when he happened on an early concept of a Magic Mirror and realized he could do even better than that. He did. In August 2016, Darian’s new Mystic Mirror won a prize in the Best Alexa Voice Service with Raspberry Pi category.
A smarter mirror with the Alexa Voice Service
Darian says his morning routine consists of running between bedroom and bathroom, trying to get ready for work. He doesn’t have an Amazon Echo in either, but he does, however, have mirrors there. That’s another reason why an Alexa Voice Service (AVS)-enabled mirror made sense.
He set his budget at a mere $100. That covered a Raspberry Pi (RPi), a two-way mirror, a refurbished monitor and speaker, some wood planks and a few other assorted items. He determined that his device would:
- Give the mirror-gazer access to all the skills available through Alexa
- Provide unique visual capabilities in the mirror face via a custom Alexa skill
- Display information only for a finite amount of time before it fades away (to make it mystical—and because Darian is light-sensitive when he sleeps)
You can build your own Mystic Mirror using the details on the Hackster site. But it was his software and Alexa that brought it to life.
Darian decided to voice-enable his Raspberry Pi, microphone and speaker with the Alexa Voice Service (AVS). That meant the Mystic Mirror’s master would have access to the built-in power of Alexa and over 4,000 third-party skills, developed using the Alexa Skills Kit (ASK). With just a word, they could control smart home devices, ask for a Lyft ride, play music from Amazon Prime accounts and much more. Best of all, since Alexa is getting smarter all the time, the mirror’s capabilities would constantly evolve, too.
Even smarter with the Alexa Skills Kit
But a mirror is inherently a visual device, and the Mystic Mirror is no exception. To endow his creation with unique talents, Darian built his own custom Alexa skill called Mystic Mirror. When the user invokes the skill, its various intents use public APIs to retrieve:
- The date and time
- Local weather
- Traffic incidents and updates
- News headlines
Mystic Mirror can also save your location preferences for these features, send short text messages (without needing your phone), and manage your contacts and calendar reminders. When you need some cheering up, you can ask Mystic Mirror how you look—it’s a mirror after all—to get a compliment. You can even take a selfie with the mirror’s built-in camera.
[Caption: How the Mystic Mirror skill handles simple intents (requiring no linked accounts or physical mirror). Diagrams for more detailed intents are available Hackster.io.]
The power lies beneath the mirror’s surface
Darian says Amazon’s templates gave him about 80 percent of what he needed to get his mirror working with both AVS and ASK. In fact, he says be coded half the skill over the 4th of July.
What makes Mystic Mirror powerful though isn’t just the data the custom skill retrieves. It’s the way it displays that data magically in the face of the mirror, instead of letting Alexa recite it.
The skill knows which intents have data to be visualized and passes the JSON data back to the mirror’s Raspberry Pi. There the RPi formats it and sends it to the display monitor behind the two-way mirror. After an interval, the software causes the images to fade mystically away.
Besides the AVS and ASK APIs, Darian used the following to allow make the Mystic Mirror perform its magic:
- AWS Lambda
- AWS IoT
- AWS SNS
- AWS DynamoDB
The Mystic Mirror skill sends data between AWS Lambda and the RPi using MQTT protocol, which Darian enabled using the AWS IoT service. “I created a second Lambda function to serve as a Lambda-based MQTT client,” says Darian. “That function receives messages [via SNS] from the Magic Mirror skill, then publishes each message onto a topic.”
Will users want a Mystic Mirror? Darian says it’s inevitable people will become more comfortable with voice technology. “As developers get better at building services that are clear without the need for displays, people get more comfortable using the technology. That’s when you’ll start to see leaps and bounds.”
Get Started with Alexa Skills Kit
Are you ready to build your first (or next) Alexa skill? Build a custom skill or use one of our easy tutorials to get started quickly.
Share other innovative ways you’re using Alexa in your life. Tweet us @alexadevs with hashtag #AlexaDevStory.