Skip to main content

IFTTT

IFTTT ("If This Then That") is a web automation service. You build applets that fire an action (send an email, post a tweet, switch a smart bulb) in response to a trigger (a webhook, a calendar event, a weather change). A TinyCLR device triggers an applet by sending a simple HTTPS GET to the IFTTT webhook URL — IFTTT does the rest.

Common SITCore use cases:

  • Notify someone when a sensor crosses a threshold (temperature, water level, motion).
  • Log an event to a Google Sheet, Notion page, or Slack channel.
  • Switch a smart-home device when the SITCore decides it's time.
  • Fire any of IFTTT's 700+ service integrations from an embedded condition.

NuGet packages: GHIElectronics.TinyCLR.Networking.Http for the HTTP request, plus whatever your network transport needs (WiFi, Ethernet, or PPP).

What you'll need from IFTTT

  1. An IFTTT account. Sign up at ifttt.com. The free tier allows a limited number of applets; IFTTT Pro lifts the cap. Verify current limits in their pricing page.
  2. Connect the Webhooks service to your account.
  3. Create an applet with the Webhooks "Receive a web request" trigger and pick whatever action service you want (email, SMS, Slack, smart-home, etc.).
  4. Pick an event name — for example, button_press. You'll send this as part of the URL.
  5. Get your Webhooks key. On the Webhooks service page, click Documentation — your unique key is shown there, along with the URL format.

The webhook URL looks like:

https://maker.ifttt.com/trigger/{eventName}/with/key/{yourKey}

Test it in a browser before flashing the device. Hitting the URL should fire the applet (you'll receive the email or whatever action you wired up).

tip

The IFTTT console UI changes periodically — for current step-by-step setup, follow IFTTT's Webhooks documentation.

Sending the trigger from TinyCLR

Once the applet is wired up, all the device has to do is send an HTTPS GET to the webhook URL when its condition fires.

using System;
using System.Diagnostics;
using System.Net;

const string iftttKey = "Paste_Your_IFTTT_Webhooks_Key";
const string eventName = "button_press";

var url = "https://maker.ifttt.com/trigger/" + eventName + "/with/key/" + iftttKey;

try{
using (var req = HttpWebRequest.Create(url) as HttpWebRequest)
{
req.KeepAlive = false;
req.ReadWriteTimeout = 5000;
req.Method = "GET";

using (var res = req.GetResponse() as HttpWebResponse)
{
Debug.WriteLine("IFTTT trigger fired: " + res.StatusCode);
}
}
}
catch (Exception ex){
Debug.WriteLine("IFTTT trigger failed: " + ex.Message);
}

Passing values

IFTTT lets your trigger carry up to three values (value1, value2, value3) that the action service can reference (for example, putting the temperature in the email body). Append them as query parameters or send them as a JSON POST body.

// As query string.
var url = "https://maker.ifttt.com/trigger/" + eventName + "/with/key/" + iftttKey
+ "?value1=" + temperature
+ "&value2=" + humidity;

For a JSON body, send a POST request with Content-Type: application/json and a payload like {"value1":"...","value2":"...","value3":"..."} — see the HTTP page for the POST pattern.

Throttling alerts

Don't send the same trigger repeatedly — IFTTT will rate-limit the webhook, and if the action is something visible (email, SMS) you don't want to spam the recipient. A simple guard: send once when the condition first becomes true, then wait before sending again.

const int alertCooldownMs = 2 * 60 * 60 * 1000; // 2 hours.
bool alertActive = false;

while (true) {
var temperature = ReadTemperature();

if (temperature < 10 && !alertActive) {
SendIftttTrigger(eventName, iftttKey, "value1=" + temperature);
alertActive = true;
Thread.Sleep(alertCooldownMs);
alertActive = false;
}

Thread.Sleep(1000);
}

API reference

NamespaceDescription
GHIElectronics.TinyCLR.Networking.HttpHTTP client classes (used for IFTTT webhooks)