Using Netlify Webhooks With IFTTT

Any time I update my site and push the changes to GitHub1, Netlify sends me an email once it has been successfully deployed (or if the deploy failed for some reason). Netlify can also send these notifications as outgoing webhooks, and even receive notifications from other services to trigger builds automatically.

Although implementing webhooks can often be complex, a basic solution for notifications can be done with IFTTT.

Build notifications

IFTTT’s Webhooks service can receive web requests (i.e., webhook notifications) to trigger actions. A custom event name is specified when creating an applet which must be included in the URL provided by IFTTT2. This allows the platform to identify which applet the request corresponds to.

I use this service to receive a push notification when a site deploy is successful. I created an applet that uses the Webhooks service to receive a web request, setting the event name to deploy_success. For the action, I chose Send a notification to the IFTTT app. Finally, I set up an outgoing webhook in Netlify, (under deploy notifications) using the URL and event name from IFTTT.

Netlify notification options

Whenever my site is deployed, Netlify sends a webhook notification to IFTTT that triggers a push notification on my iPhone. I also use the same process to be notified if a deploy has failed, using deploy_failed as the event name instead. A separate outgoing webhook notification is configured in Netlify for failed deploys.

With so many services supported by IFTTT, you can perform many different actions based upon the status of a build. For instance, you could post a tweet when a deploy has succeeded or blink your Philips Hue lights if a deploy has failed.

Build hooks

Netlify also supports incoming web requests to trigger builds (build hooks). IFTTT can send web requests using the Webhooks service as an action triggered by another service. To use this, create a new build hook in Netlify and include its URL in the applet as a Webhooks action. Any POST request that reaches this URL triggers a build.

Creating a build hook

For example, builds can be triggered on-demand using IFTTT’s Button widget service. Applets can be run when tapping it in either the Today widget in iOS or on Apple Watch.

iOS Widget

Apple Watch.png

You could also use Amazon Alexa to trigger a site build whenever you ask it to (e.g., “Alexa, trigger site build”).

IFTTT and build hooks can add scheduled post functionality to a statically generated blog. Static site generators like Jekyll can’t support scheduled posts themselves3. To include a new post dated in the future, the site has to be rebuilt on or after that date.

Using IFTTT’s Date & Time service, you can schedule a site build to automatically occur on a regular basis, even as frequently as hourly. Scheduled posts would then be included once the appropriate date and time have been reached.

Keep in mind that if you create an applet to schedule a recurring build and have another one set up for notifications, you’ll be notified each time it happens.

  1. I had been using GitLab but decided to move back. I didn’t have any issues with GitLab, I just find GitHub easier to use. 

  2. You can retrieve your URL from IFTTT’s webhooks documentation. The URL is unique to you as it includes an account key. Replace {event} with the event name specified. 

  3. I use the option future: false in Jekyll’s _config.ymlso that posts with a date in the future are skipped. Only when the date has passed are they included when the site is built.