Build a weather-driven alert system
Trigger Northwind actions on forecast conditions — e.g., snow-day email to remote workers.
Publié le 20 août 2025
Northwind’s London studio runs a hybrid week, but bad weather changes the plan. When heavy snow is forecast, someone has to remember to email the team and tell them to work from home — and that someone usually remembers at 8am, by which point half the studio is already on a delayed train.
This script moves the decision to the night before. It checks tomorrow’s forecast against a threshold and, if snow is likely, sends one clear email so everyone wakes up knowing the plan. It uses Open-Meteo, a free weather API that needs no API key, so the whole thing is a single scheduled function.
What you’ll need
- A Gmail account that can send to your team — the script sends from whoever owns the Apps Script project.
- The latitude and longitude of the location you want to watch. The script ships with London’s coordinates; swap in your own.
- Nothing else. Open-Meteo is free and keyless, so there is no setup beyond pasting the script.
The script
// Location to check — Northwind's London studio.
const LATITUDE = 51.5;
const LONGITUDE = -0.12;
const TIMEZONE = 'Europe/London';
// Snowfall threshold in centimetres. Tomorrow's forecast has to clear
// this before an alert goes out — see "Watch out for" for tuning.
const SNOW_THRESHOLD_CM = 2;
// Where the snow-day alert is sent.
const TEAM_EMAIL = '[email protected]';
/**
* Checks tomorrow's snowfall forecast and emails the team if it
* crosses the threshold. Designed to run once a day on a trigger.
*/
function checkLondonWeather() {
// 1. Build the Open-Meteo request. "daily=snowfall_sum" returns one
// total per day; "timezone" makes day boundaries align with London.
const url =
'https://api.open-meteo.com/v1/forecast' +
'?latitude=' + LATITUDE +
'&longitude=' + LONGITUDE +
'&daily=snowfall_sum' +
'&timezone=' + encodeURIComponent(TIMEZONE);
// 2. Fetch the forecast and parse the JSON response.
const res = JSON.parse(UrlFetchApp.fetch(url).getContentText());
// 3. The daily array is ordered today, tomorrow, day after... so
// index 1 is tomorrow. Default to 0 if the field is missing.
const snow = (res.daily && res.daily.snowfall_sum[1]) || 0;
Logger.log('Forecast snowfall for tomorrow: ' + snow + 'cm');
// 4. Below the threshold? Nothing to do — no email on a clear day.
if (snow <= SNOW_THRESHOLD_CM) return;
// 5. Snow is likely — send one alert so everyone has the same plan.
GmailApp.sendEmail(
TEAM_EMAIL,
'Snow day forecast',
'Tomorrow looks like ' + snow + 'cm of snow. Default to remote — ' +
'no need to come into the studio.'
);
Logger.log('Snow-day alert sent.');
}
How it works
checkLondonWeatherbuilds an Open-Meteo URL from the configured coordinates, asking forsnowfall_sum— a single total per day. Thetimezoneparameter makes “tomorrow” line up with the London calendar rather than UTC.- It fetches the URL with
UrlFetchAppand parses the JSON reply. - The
daily.snowfall_sumarray is ordered from today onwards, so index1is tomorrow’s forecast. The script logs the value so you can see what it saw even when no email goes out. - If the figure is at or below
SNOW_THRESHOLD_CM, the function returns quietly — the team only hears from it when there is something to act on. - When the threshold is crossed, it sends one plain-text email telling everyone to default to remote.
Example run
Open-Meteo returns a daily block like this:
{
"daily": {
"time": ["2025-08-20", "2025-08-21"],
"snowfall_sum": [0, 4.5]
}
}
Tomorrow’s value is 4.5cm, which clears the 2cm threshold, so the team
receives:
| Field | Value |
|---|---|
| To | [email protected] |
| Subject | Snow day forecast |
| Body | Tomorrow looks like 4.5cm of snow. Default to remote — no need to come into the studio. |
On a dry day snowfall_sum[1] is 0, the function returns at step 4, and no
email is sent.
Trigger it
This should run itself every evening so the team has the plan before bed:
- In the Apps Script editor, open Triggers (the clock icon).
- Click Add Trigger.
- Choose
checkLondonWeather, event source Time-driven, type Day timer, and set the hour to 6pm to 7pm. - Save and approve the authorisation prompt.
From then on the script checks the forecast each evening and emails the team only when snow is on the way.
Watch out for
- Forecasts change. A 6pm check can disagree with the morning reality — snow that was forecast may not fall, and vice versa. Treat the email as a heads-up, not a guarantee.
snowfall_sumis the figure that triggers the alert. To react to other conditions — heavy rain, high wind, extreme heat — swap in the matching Open-Meteo daily variable (precipitation_sum,wind_speed_10m_max,temperature_2m_max) and adjust the threshold to suit.- The threshold is a blunt instrument. 2cm is a sensible default for a city
studio, but tune
SNOW_THRESHOLD_CMto how disruptive snow actually is for your team and commute. - Open-Meteo is free for reasonable use but rate-limited. One call a day is comfortably within limits; do not loop it.
- The email sends from whoever authorised the script, and consumer Gmail caps daily sends. One message a day is nowhere near that cap, but keep it in mind if you extend the script to email people individually.
À voir aussi
Sync calendar bookings with Calendly
Bridge Google Calendar and Calendly — Northwind bookings on either side appear on both.
Mis à jour le 7 janv. 2026
Connect to an air-quality and weather feed
Build a Northwind environmental dashboard — current London AQI plus 5-day forecast.
Mis à jour le 30 déc. 2025
Build a podcast and media stats tracker
Pull Northwind's podcast download numbers across platforms into a single sheet.
Mis à jour le 10 déc. 2025
Track real-estate listings for new matches
Monitor property feeds for Northwind office hunts — alert when a match appears.
Mis à jour le 28 nov. 2025
Translate columns with a translation API
Localise Northwind text in bulk without manual work — via Google Translate or DeepL.
Mis à jour le 24 nov. 2025