Blog Content

/ /

HTTP Request, Set & Code Node – Build a Weather Alert System

These three nodes, HTTP Request, Set, and Code, handle about 80% of everything I build in n8n. Once you understand how they work together, you can connect n8n to almost any service on the internet.

In this tutorial, we will build a practical daily weather alert system that sends notifications to both email and Slack every morning at 8 AM.

1 three nodes showin in n8n HTTP Request Code and Set Nodes

What You Will Need

Before we start:

  • n8n installed (self-hosted or n8n.cloud)
  • OpenWeatherMap free account (takes 2 minutes to sign up)
  • Gmail or Slack credentials set up in n8n
  • About 20 minutes to follow along

If you haven’t set up credentials yet, check out my previous tutorial on n8n Credentials Management.

The Complete Workflow

Here’s what we’re building – a workflow that runs daily, grabs weather data, processes it, and sends alerts to multiple channels.

2 complete workflow screenshoot of n8n canvas

Let me break down each piece.

Step 1: Setting Up the Schedule Trigger

First, we need our workflow to run automatically every day at 8 AM.

Add a Schedule Trigger node and configure it:

  • Trigger Interval: Days
  • Days Between Triggers: 1
  • Trigger at Hour: 8am
  • Trigger at Minute: 0

3 Schedual trigger node

The output shows useful data like the day of week, which we’ll include in our weather report later.

Step 2: Workflow Configuration with Set Node

Here’s where the Set node comes in. I use it to define variables that I might want to change later – like the location or workflow name.

4 Workflow configuration SET NODE

I added:

  • workflow_name: “Daily Weather Alert”
  • location: “Mansehra, Pakistan”
  • alert_time: “8:00 AM”
  • Day of week: Pulled from the trigger output

Why bother with this? If I ever want to change the location, I only update one place instead of hunting through every node.

Step 3: HTTP Request Node – Grabbing Weather Data

This is where the magic happens. The HTTP Request node lets n8n talk to any API on the internet.

For OpenWeatherMap, the setup is straightforward:

  • Method: GET
  • URL: https://api.openweathermap.org/data/2.5/weather?q=Mansehra,pk&appid=YOUR_API_KEY&units=metric

5 HTTP Node Grabing weather data using api

Hit “Execute step” and you’ll see a massive JSON response with temperature, humidity, wind speed, and more. The API returns way more data than we need, which brings us to the next node.

Step 4: Cleaning Up Data with Set Node

Raw API responses are messy. The Set node helps extract exactly what we need.

I created these fields:

  • city: {{ $json.name }}
  • temperature: {{ $json.main.temp }}
  • feels_like: {{ $json.main.feels_like }}
  • weather_condition: {{ $json.weather[0].description }}
  • humidity: {{ $json.main.humidity }}

6 Extract weather fields set node data clean up

Now instead of a giant JSON blob, we have clean, labeled data ready for the next step.

Step 5: Adding Alert Logic with Code Node

The Code node lets you write custom JavaScript. I used it to add smart alerts based on temperature.

const items = $input.all();

const outputItems = items.map(item => {
  const temp = item.json.temp;
  let alertMessage = '';

  if (temp > 35) {
    alertMessage = 'Heat Warning';
  } else if (temp < 5) {
    alertMessage = 'Cold Alert';
  } else {
    alertMessage = 'Normal conditions';
  }

  return {
    json: {
      ...item.json,
      alert: alertMessage
    }
  };
});

return outputItems;
7 Code node weather alert logic

Simple if/else logic, but it transforms a basic weather report into something actionable.

Step 6: Sending Notifications

Finally, I connected both Slack and Gmail nodes to send the formatted weather report.

Slack Configuration:

8 send mesg on slack

Gmail Configuration:

9 Send gmail alert

The Results

Here’s the actual weather alert received on Slack:

10 weather alert recevied on slack

And the email version:

11 weather alter received on email

Issue I Hit: Email Formatting

My first email looked terrible – everything crammed into one line.

wrong email formating i have fixed it with br tags

The fix? I switched the Gmail node’s Email Type to “HTML” and added <br> tags for line breaks. Small change, big difference in readability.

Click here for [ERROR LOGGER] Code.

Quick Recap

  • HTTP Request Node: Connects to any API, grabs external data
  • Set Node: Cleans and transforms data, creates variables
  • Code Node: Adds custom logic when built-in nodes aren’t enough

These three nodes are the backbone of most workflows I build. Master them, and you’ll handle 80% of what n8n can do.

What’s Next?

Ready to level up? In the next tutorial, we’ll cover n8n Error Handling – because workflows break, and you need to know when they do.


Here is the full video guide on this blog post: