Add Amazon Echo Voice Control to You Smart Device

by akellyirl in Circuits > Gadgets

874 Views, 17 Favorites, 0 Comments

Add Amazon Echo Voice Control to You Smart Device

2017-01-14 19_25_28-OneNote.png

Many internet devices, including the Particle Photon used in my Smart Thermostat, use REST as a central tenet of the cloud infastructure. So for example, if you want to query the temperature downstairs:

https://api.spark.io/v1/devices/myDeviceName/tempD...

returns a JSON format string with the required info.

It’s not too difficult to write a custom Lambda Function to act on the voice commands from the Echo Dot by issuing REST commands. I used Node.js for implemention but Java and Python are also supported.

Custom Skill and Lambda Function

2017-01-14 20_09_23-OneNote.png

There are basically two things you need to do to voice enable your IoT device for use with an Echo or Echo Dot:


1 Create a Lambda Function

2 Setup a Custom Skill

The Lambda function is an Amazon Web Service (AWS) that allows you to write the function to handle the requests that come from Alexa. The Lambda function can be written in Node-js, Java or Python. It’s available to run 24/7 and is hosted on Amazon’s servers. In our situation it will handle the RESTful interface with the IoT device.

The Custom Skill consists of configuring the Actions you want to take (“Device Directives” in AWS speak), and the words you’ll say to Alexa to trigger those Actions (“Utterances” in AWS speak). It performs the task of triggering the Lambda function when you speak a phrase to your Echo Dot that matches a trigger phrase.

As an example consider a Lambda function called Hello World, whose function is to say “Hello World” whenever you trigger it. Your trigger phrase will be “Say Hi“, so you’ve also configured a Custom Skill to recognise that phrase. To trigger the Lambda Function you say: “Alexa, ask Hello World to Say Hi“. “Alexa” is the wake-word to tell the Echo Dot to listen, followed by the name of the Service/Function you’re asking it to trigger and finally the Trigger phrase. Once triggered like this, Alexa responds with the response programmed by the Lambda Function “Hello World”.

To really get to grips with this, take a few minutes to read over this Hello World example.

Making this work requires writing a Lambda function to interface with the RESTful API of Particle and configuring the custom skill. More about that in my blog.