Introduction: Voice Control Through Echo (Demo Video)

About: Photographer, Climber, Programmer, Maker, and more

How it works:

  • You place a Node.js server somewhere in the cloud that responds to the Amazon Echo's requests for your application.
  • This server can then route the requests to your raspberry pi through a WebSocket connection.
  • Your Raspberry Pi can then do things within your home to automate and control things.

In my case, I used another home automation project I created called OpenSmartHub.

This created the connection between a Node.js application running on the Raspberry Pi and the Node.js server running in Azure and allowed me to use the pre-made functionalities to automate and remote control my yamaha receiver, wemo lights, tv, led lights, fan, etc.

If you are interested in using OpenSmartHub for the home automation side, follow the setup guide on Github. Otherwise, follow Step 1 to make your own separate design.

Step 1: Create a Raspberry Pi Node.js Application

  1. Follow this guide to setup your Raspberry Pi for Node.js (it's somewhat long and already laid out in a nice format)
  2. Learn about as this is the communication layer (pretty straightforward if you have Node.js or javascript coding experience)
  3. Use the protocol to pipe a request/response between the node.js app and your local raspberry pi for home automation.
  4. For references, feel free to look at the local-hub.js and server.js where the code talks about {socket.on('actionsCalled'} and {socket.emit('actionsCalled'} respectively

Step 2: Create a Node.js App Hosted in Azure That Will Handle Your Amazon Echo's API Calls

  1. Might want to pick up an Amazon Echo before you do anything else.
  2. You will want to download and install Node.js if you haven't already.
  3. Download the code from the repository here.
  4. Create an Azure account if you haven't already and create a new web app.
  5. Using Kudu get the code into the location for your new azure web app.
  6. Join the Amazon Developer program for the Echo and create a new Echo app. (Note: In order to use this while in development on your Echo, the account needs to be the same one that the Echo is linked to)
  7. In your App information tab:
    1. Fill out your "App Name". This will act as your official app name.
    2. Fill out your "Spoken Name". You will want this to be short and simple to say in order to give it the easiest time to recognize.
    3. Give your "App Version" which will need to match the info you hand back through the API.
    4. Give your "App Endpoint" which will be your Azure webapp's URL + the api endpoint. (Example: "")
  8. In your Interaction Model:
    1. Fill out your "Intent Schema". The intent is the name of the function, slots are parameters, and the type when "literal" will give you back the speech-to-text recognized word. More info on this here.
    2. Fill out your "Spoken Utterances". They should be tab separated between the intent and the sample phrases. Something interesting to note is that they suggest that you provide a sample for every number of literal device phrases from min to max. (In my case from 1-3 words, thus the repetitions.) It also does not like it when you have multiple of the same literals anywhere in the file.. More info on this here.
  9. After this, set your app to be ready for testing and you are on your way!
  10. Call Alexa with your Spoken Name by saying "Alexa, open {YourSpokenAppNameHere}"
  11. Now you can say the commands that you've designated in both your Nodejs web app and your Amazon app declarations for your response!
Raspberry Pi Contest

Participated in the
Raspberry Pi Contest