Overview

Skill Level: Beginner

Bluemix, Node-Red, ,IFTTT, WatsonIoT, Alexa, MQTT, Javascript, RaspberryPI

This recipe shows how to integrate Alexa via IFTTT with Watson IoT Platform to control smart home (really any) device. We use a ble candle and Raspberry Pi to demonstrate how you can control a device via Alex and IFTTT (If this than that).

Ingredients

  • Bluemix account
  • Watson IoT starter app
  • A playblub and a PI see recipe 
  • IFTTT Maker Account 
  • Amazon account
  • Echo Dot or Alexa

Step-by-step

  1. The scenario

    I used the PlayBlub form my previous recipe (playbulb) you can use any device which you have setup via mqtt to Watson IoT Platform for this scenario. Here is our scenario: 

    Screenshot-2017-03-07-08.45.27

     

    Basically we say a trigger command to Alexa E.g “Alexa, trigger set candle to red” than IFTTT will raise an event and trigger an action to post a message to our Node-Red instance (http endpoint).  In Node-Red we pickup the message parse it and send a mqtt message (comand) via WIoT to our gateway (Raspberry Pi). The pi received the comand and changes the color of our candle to red (in my case via bluetooth low engery commands). Lets go through the setup steps.

     

  2. IFTTT Maker Channel setup

    Fist thing we have to do is to setup our IFTTT maker channel, so we can post to an url (http endpoint in Node-Red). Login/signup for IFTTT search for the maker and enable it. 

    Screenshot-2017-01-17-14.48.34

     

  3. Connect Alexa with IFTTT

    Next step is to connect IFTTT Alexa channel with your Amazon – it will link the channel via oAuth to your Amazon account.

    Screenshot-2017-03-07-09.32.58

  4. Create a http endpoint

    In order to receive notification from IFTTT we need to create a http endpoint in Node-Red so we can receive a post. I created http end point called http://yournodered.mybluemix.net/ifttt . You can find my Node-Red flow for Alexa here.

    Screenshot-2017-03-07-08.38.22

  5. Create a recipe in IFTTT

    Go to IFTTT and create a recipe starting with Alex (If You say “Alexa trigger  …) add your phrase like “candle red”. Save the trigger and add the Maker web request. For the Maker web request add your http endpoint like http://yourapp.mybluemix.net/ifttt , i use method post, Content Type plain text and the following message in the body 

    <<<{“ts”:”>>> {{TriggeredAt}} <<<“,”color”:”red”>>><<<,”cmd”:”setcolor”}>>>

    Screenshot-2017-03-07-09.50.16

    Now you should be able to receive a json message when you say “Alexa, trigger set candle to red”.

     

  6. References

    Presentation

    PlayBulb recipe

    YouTube

    Node-Red flow

Join The Discussion