So-called “smart devices” are becoming ubiquitous in modern households.

“Alexa, order printer ink” or “Alexa, read me my calendar” are common additions to the morning routine of packing lunches and signing field trip forms.

What if we could combine the power of data with the power of these smart devices, and deliver something like “Alexa, how is my power consumption?”

That’s exactly what we recently did as part of a demo for two of the larger energy conferences in the country—Distributech and TechAdvantage.

How Does Alexa Work?

From a user’s perspective, “Alexa” is the interface provided by Amazon to interact with “skills” that are available for download. Alexa is essentially a bot powered by Amazon Lex, which is a natural language processing service available through Amazon Web Service (AWS).

A user can interact with Alexa through a Kindle Fire tablet, a Fire TV Stick, or through the “Echo” series of smart speakers – some of which have touch screens.

A user enables a “skill”, such as a preferred weather source, music streaming service, or perhaps “question of the day”, and then the user is able to invoke that skill on any of their Alexa-enabled devices:

“Alexa, tell me about the weather”

Depending on the device – which may or may not have a screen – the Alexa service will then describe, and possibly show, information about the weather.

What Skills Are Available?

Skills for Alexa are analogous to apps for your phone, and Amazon provides a skills marketplace, analogous to your phone’s “app store”:

Developers can create Alexa content in the form of a skill, and follow a procedure to get the skill published to this marketplace.

How Do You Build A Skill?

Amazon provides several ways to build an Alexa skill, but the simplest approach is to use the Alexa Developer Console, which is a web dashboard provided for free by Amazon.

You simply start your skill, and then follow the prescribed steps to check your boxes:

Invocation Name:  This tells Alexa to launch the skill. In our case, the name we chose for our demo is “Sensus Explorer”.

So when a user says, “Alexa, launch the Sensus Explorer”, our skill is launched.

Intents: Describes the action that you want to have taken. For the purposes of our demo, we built two intents: show usage and disaggregate usage. Once you create an intent, it’s very simple to describe the utterances that should launch that intent:

So once the user invokes the skill, and launches an intent – “Alexa, how is my usage?” we simply map the intent to the code that should be executed. This can come in the form of a REST service configured at a given endpoint, or an AWS Lambda function. In our case, we built a Lambda function using NodeJS, but we could have easily used Java, Python, or other languages supported by Lambda.

Once our NodeJS code is triggered, we’re off to the races – we can do anything possible in NodeJS as long as we return a result within a reasonable time period. For demo purposes, the Stratus IQ meter is sending data to a web service. We make a call to this service to get the data that we need to build the chart of real-time data that we want to show the user. Then, we use the ChartJS library to build a chart with this data.

For showing things to the user, Alexa supports the “Alexa Presentation Language” (APL). It requires that we build a JSON object that can describe layouts, text, and images. So in order to show our chart, we have to export it to an image and post it to the web.  Then, we include the path to the image in the APL JSON document we send back to Alexa. We also describe what we want her to say.

Finally, Alexa takes our JSON document and tells the user what we have prescribed – and also shows our chart on the screen:

Why It Matters

Our little demo is fairly trivial, but it illustrates the amazing potential. Combining the power of data science and the convenience of a platform like Alexa, we could provide functionality like:

User: “Alexa, check my appliances”

Alexa: “Your air conditioner is using 30% more power this month than it did last month. Would you like me to call a repairman?”


User: “Alexa, are we being good global citizens?”

Alexa: “You are using 20% less power this week than you did during the same week last year and 17% more power than the average household in your utility. Would you like me to adjust the thermostat?”

The future is data-powered, and platforms like Alexa can make it easy to turn that data into a better world.