IfThisThenThat

 

IfThisThenThat

IfThisThenThat is a free web application that easily connects triggers and actions. If this trigger then that action. It can connect images on your phone to Instagram, install the Astronomy Picture of the Day as your Android background, even turn your phone's volume up when you've misplaced your phone. All pretty cool things, but not what this is about.

One important thing you can do with ifthisthenthat is create a web service endpoint and trigger an action whenever that endpoint is hit. Imagine your computer pinging your phone when it is getting too hot, or your intruder alarm sending you a picture, or a text message. Or your garage door telling you when it has been opened. That is more what this is about. Using an Arduino or nodeMCU to communicate with you when needed.

What follows is a step-by-step walk through of setting up an ifthisthenthat Applet. I chose to use the computer telling me it is too hot because it is a problem I have that could use a solution. So let's set up the Applet.


The first thing you need to do is go to IFTTT and sign up. Once you have signed up, you can go to the "My Applets" page by clicking on the link at the top left of the page. You will be presented with a page as shown below.

ifttt
- My Applets -

It might seem that "Get started" would be the place to start, but that takes you to the pre-built applets, which are many and varied, but it would be a dead end as far as the task at hand. Instead, click the "New Applet" button way out to the right side of the page. That takes you to the "if this then that" feature, which gives the web site its name.


ifttt
- New Applet -

"+this" represents the trigger that starts the ball rolling, and is where you need to start to build the applet. The trigger is also called a service, and clicking the "+this" takes you to a page full of services you could choose from, but in order to cut through the noise and get to the webhooks, type "web" in the search box. The Webhooks icon will appear. Also of note is the light grey "Step 1 of 6" above the search box. Don't worry, each step is simple, but some steps have a couple of pages - one option per page.


Click on the Webhooks icon to proceed to step two - "Choose trigger".

ifttt
- Choose a service -

The only trigger available is in the blue box on the left side, labeled "Receive a web request". The webhook will receive a web request and will then perform an action. Click the blue box to proceed.

ifttt
- Choose trigger -

You will be taken to a page that says “Complete trigger fields”. You have one blue box with a text box labeled “Event Name”. Put something descriptive in it, like “computer_overheated”, and click the “Create trigger” button.

ifttt

Now you are taken to a page that says “if ifttt then +that”. As before, the blue text with the plus sign, “+that”, is what you need to click. You will be taken to. a page of action services. If “SMS” is not at the top, type “sms” in the “Search services” box. Click on the green “SMS” box.

ifttt
- Then that -

After clicking the green SMS box you will be shown the "Connect SMS" page. This is where you get an important message about how many text messages you can send per month. If you exceed the limit your applet will be paused until the next month.

ifttt
- Connect SMS (1)-

Click the "Connect" button to proceed.


On the second "Connect SMS" page you are asked to enter your phone number. You will be sent a PIN that you must enter in the PIN text field in order to continue. There is a "Retry" button in case you don't get the first text.

ifttt
- Connect SMS (2)-

The next screen is the “Choose action” page, with a green box on the left labeled “Send me an SMS”. Click that green box.

ifttt
- Choose action -

This is the “Complete action fields” page. The text I'm describing here doesn't match the picture. I went back after I built it and changed the text, and this description, for a project. There is a green box labeled “Send me an SMS”, with a “Message” field filled out. The message field is where you enter the text of the message. There is a button labeled “Add ingredient”. Click that to see what fields are available. I typed “Computer temperature alert: “ then clicked “Add ingredient” and selected “Value1”. Then I added “ and “, clicked “Add ingredient” again, and selected “Value2”, and finished the sentence with a period. When you have the message the way you want it (you can change it later), click “Create action”.

ifttt
- Complete action fields (before) -

ifttt
- Complete action fields (after) -

You will be taken to a page that shows the recipe with a “Finish” button at the very bottom. Click “Finish”.

ifttt
- Review and finish -

You will see a page with a list of all of your webhooks, which at this point will be only one. In the blue box is a white switch that is in the “On” state. That means your applet is complete and running.

ifttt

To test your applet, click on “My Applets” on the upper left of the page. you will see the applet in a blue box. Click the “Documentation” button in the upper right of the page and you will see a tool for making a curl request. In the URL is a box that just says “{event}”. Put your cursor there, and type “computer_overheated”. Put your cursor in the empty field following “value1”. Type “45”. Put "25" in the "value2" field. Click the “Test it” button at the bottom of the page. It should say “Event has been triggered” on a green band at the top of the page. Within seconds you will receive an SMS message “Computer temperature alert: 45 and 25”. You can copy the curl request and run it from the command line of your ’nix-like system to trigger the response.


ifttt

The URL in the image above, right below where it says "Make a POST or GET web request to:" is your very own web service URL. You can come back anytime and grab it by clicking on your username, then selecting "Services", Then clicking on the Webhooks icon, and finally the documentation button. It will take you to the page shown above. Enter the event name and the url will change to what you want. Do a copy-paste from the URL in the curl command into your code, grabbing only the URL.


So there are a few steps in creating an applet for your IoT project to use when communicating, but none of them are hard. You need to be prepared with your phone and your phone number. You need to think of a name for the event that is descriptive enough to be unique among your events.

Arduino Board Logo

 

Arduino-Board is the go-to source for information on many available Arduino and Arduino-like boards, tutorials and projects.

Help and Support

Arduino-Board

Stay updated

Sign up if you would like to receive our once monthly newsletter.