Opening Problem Statement
Meet Sarah, a community planner responsible for organizing outdoor events in multiple cities. Every day, she spends at least 30 minutes scouring various weather websites to get the latest updates—temperature, humidity, wind speed, and weather conditions—so she can decide whether it’s safe to proceed with the day’s agenda. This manual process not only wastes her valuable time but also increases the chances of mistakes due to inconsistent sources or delayed information.
Imagine if Sarah had an automated way to instantly receive accurate weather details tailored to her needs without opening a browser or switching apps. She could save hours weekly and make confident decisions quickly, preventing event cancellations or last-minute chaos.
What This Automation Does
This n8n workflow is designed specifically to automate the retrieval and formatting of real-time weather data for any city. When triggered, it fetches the latest weather information from OpenWeatherMap and delivers a neatly structured response with key details. Here’s what happens:
- Receives a city name input via a webhook URL (easy to integrate into any app or service)
- Fetches current weather details including temperature in Celsius, humidity percentage, wind speed, and weather description
- Formats the data into a clear, user-friendly JSON output for easy consumption
- Supports accurate location identification by including city and country code
- Allows rapid access to up-to-date weather insights without manual browsing
By automating this process, users like Sarah can save up to several hours each week and reduce errors in weather-dependent decisions.
Prerequisites ⚙️
- n8n account with workflow execution privileges
- OpenWeatherMap API key credential configured in n8n 🔑
- Access to a webhook URL endpoint (automatically generated by n8n)
- Optional: Ability to trigger webhook requests from external apps or scripts to provide city names dynamically
Step-by-Step Guide
Step 1: Create a New Workflow and Add a Webhook Node
In your n8n editor, click New Workflow, then + Add Node. Search for and select the Webhook node.
Set the path to a unique identifier like 39f1b81f-f538-4b94-8788-29180d5e4016 (or any custom string). This will be the URL endpoint that triggers the workflow.
Once saved, you will see a webhook URL formatted like https://your-n8n-domain/webhook/39f1b81f-f538-4b94-8788-29180d5e4016. This URL accepts HTTP requests that start the workflow.
Common mistake: Forgetting to copy the webhook URL before exiting or not setting the path uniquely.
Step 2: Add and Configure the OpenWeatherMap Node
Click + Add Node and select OpenWeatherMap.
Set the City Name parameter using an expression to fetch the city name dynamically from the webhook input: {{ $json["body"]["city"] }}.
Ensure you have added your OpenWeatherMap API credentials in n8n under credentials.
This node will call the OpenWeatherMap API to get the current weather for the requested city.
Common mistake: Not entering the API credentials or incorrectly typing the city parameter.
Step 3: Add a Set Node to Format Weather Data
Add a Set node. This node extracts and formats specific fields from the OpenWeatherMap API response.
Under Values > String, add these key-value pairs using expressions:
- tempC:
{{ $json["main"]["temp"] }} - humidity:
{{ $json["main"]["humidity"] }} - windspeed:
{{ $json["wind"]["speed"] }} - description:
{{ $json["weather"][0]["description"] }} - city:
{{ $json["name"] }}, {{ $json["sys"]["country"] }}
Enable Keep Only Set so that only these fields appear in the output, making it clean and concise.
Common mistake: Forgetting to enable the “Keep Only Set” option which results in cluttered output.
Step 4: Connect the Nodes
Ensure your node connections follow this order:
- Webhook triggers OpenWeatherMap
- OpenWeatherMap triggers Set
This sequence ensures that upon receiving a city name, the API is called and the data is formatted correctly.
Step 5: Activate and Test Your Workflow
Save and activate the workflow.
Then, send a POST request to your webhook URL with a JSON body containing a city, for example:
{
"city": "London"
}You should see a JSON response with temperature, humidity, wind speed, description, and city name with country code.
Tip: Use tools like Postman or curl for testing the webhook invocation.
Customizations ✏️
1. Change Temperature Unit
In the OpenWeatherMap node, add a parameter or adjust the API call settings to retrieve temperature in Fahrenheit if desired (check OpenWeatherMap docs for unit parameter).
2. Include Additional Weather Details
Modify the Set node to extract other information like pressure or cloudiness by adding extra expression fields.
3. Trigger Weather Check at Scheduled Intervals
Add a Cron node (not in current workflow) before the Webhook to run the workflow automatically every hour/day.
Troubleshooting 🔧
Problem: “Webhook Not Responding”
Cause: Incorrect webhook path or inactive workflow.
Solution: Verify webhook path in the node and ensure the workflow is active.
Problem: “OpenWeatherMap API Error”
Cause: Missing or invalid API key.
Solution: Recheck OpenWeatherMap credentials in n8n and regenerate the API key if necessary.
Pre-Production Checklist ✅
- Confirm the webhook URL path is unique and correctly copied.
- Test with multiple city names to ensure API responses are accurate.
- Verify that API credentials are correctly set and have active quota.
- Check that the Set node outputs only the intended fields.
Deployment Guide
Once tested, activate your workflow in n8n.
Use the webhook URL to integrate this weather automation into your apps, websites, or scripts.
Monitor execution logs in n8n for any runtime issues and adjust as needed.
FAQs
Can I use this workflow with cities outside the OpenWeatherMap free tier limits?
OpenWeatherMap supports global cities; however, free tier has API call limits. Monitor usage accordingly.
Is my data safe when using the webhook?
This webhook only receives city names, so no sensitive data is transmitted. Ensure your n8n server is secure for best practices.
Can I extend this workflow to send alerts?
Yes, you can add notification nodes like Email or Slack after the Set node to alert based on weather changes.
Conclusion
By following this guide, you’ve built a custom n8n automation that instantly fetches and formats real-time weather data from OpenWeatherMap through a simple webhook trigger. This setup saves you time, increases accuracy, and allows integration in various apps requiring weather insights.
Imagine the countless hours saved from manual weather monitoring and the confidence gained from always having up-to-date data at your fingertips.
Next, consider expanding this workflow to schedule automated weather updates, integrate with SMS or messaging platforms for alerts, or enrich your dashboard applications with live environmental data.
With n8n and OpenWeatherMap, weather automation is just the beginning of smarter workflows customized by you!