EBC Exercise 32 ifttt

ifttt (If This Then That) is a slick web service that lets you attach event triggers to actions. See the ifttt website for examples of what it can do. Here I'll show you how to use the Maker channel to trigger events from the Bone and have the Bone receive events.

Sending an SMS message from the Bone
There are three steps needed to send SMS messages, set up ifttt, edit a script on the Bone, and then run the script.

Set up ifttt

 * 1) Create an account on ifttt and
 * 2) then click Create a Recipe
 * 3) next click the big blue this
 * 4) type "make" in the search box and click "Maker"
 * 5) click the blue "Receive a web request"
 * 6) enter "sms" for the Event Name and click "Create Trigger"
 * 7) click on the blue "that"
 * 8) enter "sms" and click on "SMS"
 * 9) click on the blue "Send me an SMS"
 * 10) enter a message to send.  You can click on the blue flask in the upper right to insert things into the message.
 * 11) click "Create Action"
 * 12) edit the Recipe Title if you want.  (I remove "update phone number")
 * 13) click "Create Recipe"

Set up the Bone
The file send.js on github is a simple example that triggers ifttt events.
 * 1) Go to https://ifttt.com/maker channel and copy your key
 * 2) edit send.js and paste you key.
 * 3) make sure the event matches the event name you entered ("sms").
 * 4) save your file and make sure it's executable.

Run the script
Once everything is set up all you do is run: bone$ ./send.js https://maker.ifttt.com/trigger/sms/with/key/b...4?value1=My&value2=Test%202&value3=BeagleBone Congratulations! You've fired the sms event

You are allowed to pass on three parameters (value1, value2 and value3), which the script does. You can set your recipe to send these values in the sms message.

Getting triggers events from ifttt
ifttt can be set up to access a web page when a trigger occurs. Here will run a web server on the Bone and have ifttt access it when you get an email.

The web server
The file receive.js on github is a simple web server. If the page /on is accessed, the LED on P9_14 is turned on. If \off is accessed the LED is turned off.

Setting up your host computer
These instructions assume your Bone is attached to your host over the USB so the Bone isn't visible to the world. You can make it accessible by using port forwarding. host$ cd exercises/setup host$ ifconfig Note which interface your host is using. It may be eth0 or wlan0, or something like it. host$ .\portForward.sh eth0 9090 Now when you access your host on port 9090, it will forward the request to the Bone.

Setting up ifttt

 * 1) Browse to https://ifttt.com/myrecipes/personal and click "Create a Recipe"
 * 2) click the blue "if"
 * 3) search and click gmail
 * 4) click "Any new email in inbox
 * 5) click "Create Trigger"
 * 6) click "that"
 * 7) search and click "Maker"
 * 8) click "Make a web request"
 * 9) if in the URL for your Host computer, port 9090.  Mine is 137.112.41.36:9090/on
 * 10) select Method: GET, Content Type: text/plain and put in the Body where you want
 * 11) click "Create Action"
 * 12) clean up the Recipe Title and click "Create Recipe"

Start the server and test
bone$ .\receive.js Listening on 9090 Send an email to your gmail account and the bone should respond with path: /on {}