IFTTT users have long wanted the ability to create multiple triggers, so that you could for example, turn off your lights and the heating, but turn on your security cameras when you’re set to go out.
We got excited back in November when they made that very thing possible, just with one big catch — only service providers could do it. They’ve promised to make such functionality available for consumers some time in 2017, but we don’t have details yet about how that might work or what it’ll cost. So for those who don’t want to wait — here’s a guide on how you can use the IFTTT Webhooks with Glitch, to add the ability to trigger multiple IFTTT applets for free.
For those new to Glitch, it’s a free service that makes it easy to code and create apps and bots. It’s like an App Store connected to CodePen connected to Heroku. What’s more, we start you off with example projects rather than a blank screen. So for example, here’s a project that implements multiple triggers for IFTTT so all you need to do is configure a few things.
To get started, click the following link to remix the example app. All this does is automatically create an app for us on Glitch, which contains all the code we need to implement multiple IFTTT triggers. Then there are two stages to configuring things: triggering your Glitch app on IFTTT, and letting your Glitch app know which of your IFTTT applets to trigger in response.
Stage 1: Triggering your Glitch app
In IFTTT, create a new applet by selecting ‘New Applet’. For the ‘if’ condition, select whatever service notification you want to initially trigger your Glitch app. So for example, if you wanted to to trigger things from your iPhone’s lock screen, then you could use the ‘Button widget’ with the ‘button press’ action.
For the ‘then’ condition, search and select ‘Webhooks’, and use the ‘Make a web request’ action. Set the URL to your Glitch project URL — this has the format of ‘https://project-name.glitch.me/' and is what loads when you click ‘Show’ on Glitch. Set the Method to ‘POST’ and Content Type to ‘application/json’. You don’t need to set anything in the ‘Body’.
Your configuration, should look a bit like this, but with your own URL:
Now when that service triggers, your Glitch app will receive a request. All that’s left now is to get your Glitch app to then trigger multiple services in IFTTT.
Stage 2: Setup your Glitch app to trigger multiple services:
From your Webhooks settings page in IFTTT, copy and paste the URL value for the IFTTT_MAKER_URL variable into the .env file in your Glitch project.
Then, for each service that you want your Glitch app to trigger you need to create a new applet in IFTTT:
- Create a new applet by selecting ‘New Applet’.
- For the ‘if’ condition, search and select ‘Webhooks’, and use the ‘Receive a web request’ action. Set an event name, and set that event name against the IFTTT_SERVICE_X variable in the .env file in your Glitch project. E.g. if I created an event name called ‘lights_on’, I would set IFTTT_SERVICE_1=lights_on in .env.
- For the ‘then’ condition, search and select whatever service you want to trigger, such as turning on your lights. Click ‘finish’ to create the applet.
Repeat this for each service that you want triggered. By the end, your .env file will look a bit like:
And that’s it! With those two steps complete, you’ve configured your Glitch app to trigger multiple IFTTT applets when it gets triggered. So for example, now I can hit the IFTTT Do button on my phone and it’ll turn my lights off, set the thermostat to away, and turn my cameras on.
Got an idea for another IFTTT app? Check out the Glitch community page for example apps and building blocks to help you get started quickly.