We are now habituated to control applications and devices through voice control. We now have Amazon Echo and Alexa Skills Kit (ASK) that is now helping developers to utilize voice control feature with more certainty for most applications and devices.

This new API will now enable developers to control and interact with connected devices with even more certainty than ever before. With the new Smart Home Skill API already in place, most connected devices can now be equipped to control right from the cloud.

Amazon Web Services (AWS) and Alexa Skills Kit (ASK) together making this possible to control all types of devices through voice control and cloud-based interaction. This AWS, when unleashed for a majority of IOT devices, can really help in creating new experiences with voice-controlled interactions.

Jointly called as AWS IOT by the company and developers, it can really transform the user experience to the fullest. For developers who already have a physical device in hand and are looking for giving it the edge of AWS IOT, the AWS SDK will make the quick documentation available for an instant start.

For offering a concrete and specific example of how it happens we can take an industrial use case. The promise is huge for any industrial setting since one can remotely deliver control for equipment. Thanks to the Alexa Skills Kit a physical device can now be simulated to the benefit of the developers to perform all the steps.

While one needs to have a complete prior knowledge of the AWS Platform, in case a detailed knowledge goes missing one can just attend AWS training section and sharpen the skill set.

Let us now describe in detail how you can use Alexa and the AWS platform for creating your own custom voice-enabled IoT apps.

Shaping a Simulated Physical Device through AWS IoT

If you want to create a representative physical device that offers the simulation of the actual device, you can do it by using AWS IoT. Being a managed cloud platform through with a wide variety of devices it can interact easily without any security glitches. AWS IoT offers unflinching and consistent support to billions of devices and trillions of messages with the ability to route reliably and securely a variety of messages to the plethora of AWS endpoints and several other devices. Thanks to the support of AWS IoT, the apps allow you communicating with a whole array of devices irrespective of whether they are connected or not.

By empowering the devices with AWS IoT based apps you give them the edge of having built-in integration of AWS solutions. With AWS IOT at your side, one can build a wide array of apps capable to collect, process, analyze and take actions generated through the interconnected devices without really having to deal with the challenge of managing the data infrastructure.

Creating the Virtual Equivalent of the Physical Device

Now we need to look at the particular steps involved in creating the virtual equivalent of the physical devices you need to take control. For this you need to perform the following steps within the console:

  • First click on ‘Create a resource’ to begin with
  • Then click on ‘Create a thing’
  • Now type the ‘device name’ you want to create in the area entitled to name
  • Now just click on ‘Create’ followed by a click on the ‘device name’

As soon as you finished going through this process the details of the last created ‘thing’ can be seen on the right panel. It is visible now without being ascribed any state. From the right panel just copy the value from ‘REST API endpoint’ so that you can use it later on.

Interacting with the representative simulated device using ‘Device Shadows’

As of now you must have understood how AWS IoT helps you creating and shaping a consistently appearing, virtual version of the device which looks more like the shadow state of the actual device you need to create. This shadow state of the device is still robust to allow other apps and devices reading messages and interacting with the devices. With the shadow state of the devices, we can easily refer to the last registered state of the device and accordingly can refer to the destined future state of the device. This reference to the present and future states of the device persists with the shadow state and can be accessed irrespective of the availability of the connection. AWS IOT by comparing the two APIs will guide the developers to breach the difference only to build the desired device.

Transforming the Shadow State Using Alexa Skill

Now the last mile of the challenge remains in transforming this shadow state of the device by using Alexa Skill. To help you understand the process better let’s simulate a physical object with the AWS IoT Device SDK and the present attributes of the state of the device. The process can be described as follows:

  • Go to the AWS Console where we were earlier
  • Now click on the ‘update shadow’ just in the right panel

Following this just copy and paste the respective code mentioned here below.

“desired”: {},

“reported”: {“pump”:0}


Now the following steps will show up:

You need to click on the ‘update shadow’ for including the new attributes within the shadow state. Now the Shadow state will include the newly updated state of the device.

The above-mentioned steps and explanations are correct if you have a physical device to connect to the AWS IoT. If you do not have a physical device to connect you can still do the same and we will explain the process now.

Creating and Updating Device Shadow without Physical Device

While for controlling a physical device you can connect the same just by updating the attributes in the ‘desired’ section of the Shadow state through the AWS IoT API, in case you do not have a physical device in place to connect you need to update ‘desired’ section of the Shadow state by using Alexa Skill and the AWS IoT API fetched from AWS Lambda.

Once you become familiar and gain some level of expertise with the Alexa Skills Kit having the commands for creating Alexa skill, use the below mentioned code to tweak the Shadow state of the desired Thing and gain total control over your connected device.

Just put the below-mentioned code on top of your AWS Lambda function to help with loading the libraries and change the endpoint by pasting ‘REST API Endpoint’ value you have copied previously. Do not forget to extract the below-mentioned part: XXXXX.iot.us-east-1.amazonaws.com.

//Environment Configuration

var config = {};

config.IOT_BROKER_ENDPOINT   = “XXXXXX.iot.us-east-1.amazonaws.com”.toLowerCase();

config.IOT_BROKER_REGION    = “us-east-1”;

config.IOT_THING_NAME   = “waterPump”;

//Loading AWS SDK libraries

var AWS = require(‘aws-sdk’);

AWS.config.region = config.IOT_BROKER_REGION;

//Initializing client for IoT

var iotData = new AWS.IotData({endpoint: config.IOT_BROKER_ENDPOINT});

Then you can place the following as a function to be executed when your intent triggers, more precisely when the ‘onIntent’ function is referenced inside the Alexa Skills Kit template.

* Activate the pump using AWS IoT Device Shadow

function activatePump (intent, session, callback) {

var repromptText = null;

var sessionAttributes = {};

var shouldEndSession = true;

var speechOutput = “”;

//Set the pump to 1 for activation of the device

var payloadObj={ “state”:

{ “desired”:




//Prepare the parameters of the update call

var paramsUpdate = {

“thingName” : config.IOT_THING_NAME,

“payload” : JSON.stringify(payloadObj)


//Update Device Shadow

iotData.updateThingShadow(paramsUpdate, function(err, data) {

if (err){

//Handle the error here


else {

speechOutput = “The pump has been activated!”;


callback(sessionAttributes,buildSpeechletResponse(intent.name, speechOutput, repromptText, shouldEndSession));




Integrating all these components you can finally achieve the intended setup.

Testing the Final Setup

Now when you need to test the entire setup with the configuration mentioned above you invariably need to see it from the internal perspective of the device. By using the skill for each specific action the device AWS IOT Device Shadow will be updated.

After the changes are updated in the device shadow, the AWS IoT service will send several notifications in the form of MQTT which is basically a publish/subscribe protocol for the IoT space. This protocol basically allows your device listen to selective topics. Physical devices by knowing the actions that turn the device from existing restful state to the desired state activate the device for certain actions.

When you need to do the same without a physical device listen to the same MQTT topic that the physical device is designed to listen and off this just go through the following steps with pin the console:

Go to the ‘MQTT Client’ tab placed on top of the screen

Now click on the ‘Generate client ID’ tab

  • Now just click on ‘Connect’
  • Thereafter, click on the ‘Subscribe to topic’
  • Now, type the value $aws/things/thingName/shadow/update/delta
  • Now click on ‘Subscribe’
  • Now your Alexa Voice Simulator is ready for use in an Alexa powered device or on the developer portal.

An array of Alexa enabled devices can use the simulator such as Amazon Echo, Echo Dot, Amazon Tap, AlexaPi, etc.

(Article Source From https://goo.gl/6mn4wM)