Showing posts with label OpenWeather. Show all posts
Showing posts with label OpenWeather. Show all posts

Monday, 13 April 2026

n8n + Weather API

How to Use n8n with a Weather API for Alerts and Automation

Build smart weather-based workflows for alerts, logging, dashboards, and IoT using n8n and a Weather API.

In this tutorial, you will learn:
  • How to connect n8n to a Weather API
  • How to read temperature, humidity, and rain data
  • How to trigger alerts using IF conditions
  • How to send notifications to Telegram, Gmail, or Google Sheets
  • How to expand the flow for smart home or IoT projects

Why Use n8n with a Weather API?

n8n is a powerful automation platform that helps you connect apps, APIs, and logic without building a full backend from scratch. A Weather API gives you real-time data such as temperature, humidity, wind speed, and weather conditions.

When you combine both, you can build workflows like:

  • Send Telegram alerts when rain starts
  • Email yourself when temperature gets too high
  • Log weather data into Google Sheets every hour
  • Trigger IoT webhooks for fans, pumps, or warning systems
  • Create weather dashboards for home, office, or city monitoring

What You Need

  • An n8n instance
  • A Weather API key
  • A city or location to monitor
  • An output app like Telegram, Gmail, Google Sheets, or Webhook

For beginners, OpenWeather is one of the easiest APIs to use.

Basic Workflow Structure

[Schedule Trigger]
        ↓
[HTTP Request]
        ↓
[IF Node]
        ↓
[Telegram / Gmail / Google Sheets / Webhook]

This flow checks the weather on a schedule, evaluates the result, and performs an action when a condition is met.

Step 1: Add a Schedule Trigger

In n8n, add a Schedule Trigger node. This decides how often the workflow checks the weather.

Suggested schedule examples:
  • Every 30 minutes
  • Every 1 hour
  • Every morning at 6:00 AM

For rain or storm alerts, checking every 15 to 30 minutes is usually enough.

Step 2: Add an HTTP Request Node

Next, add an HTTP Request node to call the Weather API.

https://api.openweathermap.org/data/2.5/weather?q=Manila,PH&appid=YOUR_API_KEY&units=metric

Replace YOUR_API_KEY with your actual API key. This request returns live weather data for Manila in Celsius.

Recommended settings:
  • Method: GET
  • Response Format: JSON

Step 3: Understand the Response

A typical Weather API response looks like this:

{
  "weather": [
    {
      "main": "Rain",
      "description": "light rain"
    }
  ],
  "main": {
    "temp": 29.5,
    "humidity": 84
  },
  "wind": {
    "speed": 3.6
  },
  "name": "Manila"
}

The most useful fields are:

  • weather[0].main = general weather condition
  • weather[0].description = detailed condition
  • main.temp = temperature
  • main.humidity = humidity percentage
  • wind.speed = wind speed
  • name = city name

Step 4: Add an IF Node for Conditions

Now add an IF node to create your alert logic.

Example 1: Rain Alert

{{$json["weather"][0]["main"]}} = Rain

Example 2: High Temperature Alert

{{$json["main"]["temp"]}} > 35

Example 3: High Humidity Alert

{{$json["main"]["humidity"]}} > 80

You can use a single IF node or add multiple branches depending on your needs.

Step 5: Send the Alert

Connect the true path of the IF node to your output app.

  • Telegram for instant mobile alerts
  • Gmail for email notifications
  • Twilio for SMS alerts
  • Google Sheets for weather logging
  • Webhook for IoT triggers

Example Telegram message:

Weather Alert
City: {{$json["name"]}}
Condition: {{$json["weather"][0]["main"]}}
Details: {{$json["weather"][0]["description"]}}
Temperature: {{$json["main"]["temp"]}}°C
Humidity: {{$json["main"]["humidity"]}}%

Optional: Clean the Data with a Set Node

To make your workflow easier to manage, add a Set node before the IF node and keep only the fields you need.

{
  "city": "{{$json['name']}}",
  "weather": "{{$json['weather'][0]['main']}}",
  "description": "{{$json['weather'][0]['description']}}",
  "temp": "{{$json['main']['temp']}}",
  "humidity": "{{$json['main']['humidity']}}"
}

This makes the next nodes cleaner and easier to read.

Practical Use Cases

1. Rain Notification System

Send a message to your phone or group chat whenever rain is detected in your city.

2. Smart Home Automation

Trigger a webhook to turn on a fan, close windows, or activate a pump based on weather conditions.

3. School or Office Safety Alerts

Notify staff when severe heat, rain, or wind conditions are detected.

4. Weather Logging Dashboard

Save weather data every hour to Google Sheets or Supabase for reports and charts.

5. IoT and ESP32 Integration

Use n8n as the automation layer between the Weather API and your hardware system.

Tips for Better Workflows

  • Use metric units for Celsius values
  • Add error handling in case the API fails
  • Store your API key securely in n8n credentials or environment variables
  • Avoid duplicate alerts by adding cooldown logic
  • Log alerts so you can review what happened later

Example Advanced Flow

[Schedule Trigger]
        ↓
[HTTP Request: Weather API]
        ↓
[Set Node]
        ↓
[IF: Rain?]
   ├── Yes → [Telegram Alert]
   └── No  → [Google Sheets Log]

Final Thoughts

If you are building automations, dashboards, or smart alert systems, n8n plus a Weather API is a very practical combination. It is simple to set up, flexible to expand, and useful for both beginners and advanced users.

You can start with a basic rain alert, then expand into Google Sheets logging, Telegram notifications, Supabase storage, or even IoT automation for devices and sensors.

Conclusion

Using n8n with a Weather API is one of the easiest ways to build real-time automation based on environmental data. With just a few nodes, you can monitor weather conditions, trigger alerts, log history, and connect the workflow to other apps or devices.

```

n8n Telegram Bot Tutorial (Step-by-Step Automation Guide)

n8n + Telegram Automation Tutorial Build your own Telegram bot using n8n — send alerts, automate messages, and conne...