This respository contains an n8n workflow that automates daily weather tracking. It fetches real-time weather data for multiple cities, detects alert conditions (Rain, Snow, Heat, Frost), logs the data to a Supabase Postgres database and emails a formatted HTML summary.
- Multi-city support: loop through a configurable list of cities defined by latitude/longitude for precision.
- Smart alerts: flags Rain/Snow, Heat (temperature ≥ 32°C), Frost (temperature < 0°C).
- Robust error handling: continues processing remaining cities when one API call fails; sends a failure notification for that city.
- Data persistence: logs structured records to Supabase including raw API response.
This workflow uses the OpenWeatherMap API (https://openweathermap.org/api).
- Sign up for a free OpenWeatherMap account and generate an API Key.
- In the n8n workflow, find the HTTP Request node that calls the current weather endpoint. Inside the "Query Parameters (JSON)" or params section, replace the placeholder with your API key:
{
"lat": {{ $json.lat }},
"lon": {{ $json.lon }},
"appid": "YOUR_ACTUAL_API_KEY",
"units": "metric"
}Notes:
- Use
units: "metric"to receive temperatures in °C. For °F useimperial.
To add or remove cities, edit the first Code node (Cities with coordinates) in the workflow. Use the following format (JavaScript):
return [
{ json: { city: "London", lat: 51.5074, lon: -0.1278 } },
{ json: { city: "New York", lat: 40.7128, lon: -74.0060 } }
];Each item must include city, lat, and lon.
Create a Supabase project (https://app.supabase.com) and run this SQL in the editor to create the table:
create table weather_logs (
id uuid default gen_random_uuid() primary key,
run_at timestamp with time zone default now(),
city text,
temperature float,
temperature_unit text,
condition text,
humidity int,
wind_speed float,
alert_type text,
raw_response jsonb
);Connect to Supabase from n8n by creating a Credential that includes your Project URL and Anon Key (Project Settings > API).
The workflow uses the Gmail node to send daily summaries and error alerts.
Open the Gmail node(s) and configure your SMTP credentials:
- Credential to connect with: Connect your gmail account by adding OAuth2 connection
- To: your email address
- Format: HTML
Test the connection before activating the workflow.
Import:
- Open your n8n instance.
- On the top-right menu of the canvas, select
Import from File. - Choose the provided workflow JSON file.
Test (manual run):
- Open the imported workflow on the canvas and click
Execute Workflow. - Watch the node executions, green is success. If a node fails, open its error output to debug.
- Check your email inbox for the summary and Supabase table for new rows.
Activate (schedule):
Toggle the Active switch to True to enable the schedule trigger (Schedule Trigger node). Recommended default: daily at 08:00 AM.
- Cities with coordinates (Code): returns the array of cities to process.
- HTTP Request (OpenWeatherMap): fetches the current weather for the city's lat/lon.
- Function node (Normalize data): extracts fields (temperature, humidity, wind speed, condition), determines alert type (Rain, Snow, Heat, Frost) and shapes data for DB insertion.
- Supabase node: inserts a row into
weather_logswithraw_responsestored as JSONB. - Summary text node: aggregates processed city results into a single HTML email body.
- Email node: sends the summary to recipients.
- Error Email node: receives failure details when a city's API call or a critical node fails.
- For per-city API calls and DB inserts, enable
Continue On Fail(or catch errors in a Function node) so one failure doesn't stop the entire run. - Collect error details (city, error message, timestamp) and send a failure email via the Error Email node.
- No email: verify SMTP host, credentials and spam folder.
- Supabase insert fails: check table schema, RLS policies and that the n8n host can reach Supabase.
- HTTP Request errors: verify lat/lon, API key and OpenWeatherMap rate limits.
Created: 2025-12-20