Opening Problem Statement
Imagine Julia, a developer working on a travel website, who needs to provide visitors with up-to-date weather information instantly based on their city input. Without automation, Julia spends hours writing and testing code to pull weather data from APIs, handle query parameters, and craft proper responses for each user request. The process is cumbersome, time-consuming, and prone to errors — resulting in delayed and inconsistent weather updates that frustrate site visitors and cost Julia precious development hours.
Julia’s specific pain point is the repetitive coding and manual testing required each time a user requests weather details for a city. Handling different city inputs, making API calls, and composing readable weather summaries also present significant complexity, especially when scaling this across multiple cities or languages.
What This Automation Does
This n8n workflow drastically simplifies Julia’s task by automating the entire chain — from receiving user requests to delivering human-friendly weather updates. Here’s what happens when it runs:
- Receives a web request on a defined webhook URL containing a city query parameter.
- Extracts and sets the city name from the incoming request, defaulting to “berlin,de” if no city is provided.
- Calls the OpenWeatherMap API to fetch current weather data for the specified city.
- Formats the temperature and feels-like metrics into a readable text response.
- Returns the crafted weather summary as the webhook response instantly.
By implementing this, Julia eliminates manual API request setups and response handling for each user query, saving hours of coding and testing time. The workflow responds in real-time, enhancing user experience and making the app more dynamic with minimal effort.
Prerequisites ⚙️
- n8n account with access to create workflows and webhooks.
- OpenWeatherMap API key🔑 — you must have a valid API key from OpenWeatherMap.
- Webhook URL 📡 — n8n automatically generates webhook endpoints for you to accept HTTP GET requests.
- Basic JSON and HTTP understanding (helpful but not required).
Step-by-Step Guide to Build the Weather Webhook
Step 1: Set up the Webhook to Receive Requests
Navigate to the n8n editor, click + Add Node → select Webhook to create a webhook listener.
Set the HTTP Method to GET and provide a path, e.g., weather. This path will be part of the public URL your users query with city parameters.
You should see a webhook URL generated, something like: https://your-n8n-instance/webhook/weather.
This will listen for incoming GET requests containing query parameters such as ?parameter=London,uk.
Common mistake: Forgetting to set the method to GET or specifying the wrong path breaks the webhook trigger.
Step 2: Extract the City Parameter Using the Set Node
Add a Set node connected from the Webhook node to extract the city query parameter.
Click Set node, add a new string field named city and set its value to {{ $json["query"]["parameter"] || 'berlin,de' }}.
This expression fetches the “parameter” query if present; otherwise, it defaults to “berlin,de”.
You should see the city value neatly extracted in the node’s output data.
Common mistake: Typo in the expression or wrong field names causes failures in resolving the city parameter.
Step 3: Call OpenWeatherMap API to Get Weather Data
Add the OpenWeatherMap node and connect it to the Set City node.
Set the cityName parameter to {{ $json["city"] }} to dynamically use the extracted city name.
Choose language as English.
Fill in your OpenWeatherMap API credentials 🔑 in the credentials section.
This node will send a live API request and fetch weather data including temperature, feels_like temperature, city name, and other details.
Common mistake: Not entering your API key or incorrect city names leads to API errors.
Step 4: Format the Weather Response Text
Add another Set node called Create Response and connect it from the OpenWeatherMap node.
Create a string field named data and enter this template:
=It has {{$json["main"]["temp"]}}°C and feels like {{$json["main"]["feels_like"]}}°C in {{$json["name"]}}This formats the temperature data nicely for user readability, e.g., “It has 12°C and feels like 10°C in Berlin.”
Common mistake: Forgetting to use correct JSON fields from the OpenWeatherMap response results in empty or wrong output.
Step 5: Test the Workflow
Activate the workflow and open your webhook URL with query parameters in a browser or API client like Postman. For example:
https://your-n8n-instance/webhook/weather?parameter=london,uk
You should receive the formatted weather string immediately.
If the parameter is missing, it defaults to Berlin’s weather.
Customizations ✏️
- Change default city: In the Set City node, modify
'berlin,de'to your preferred fallback location. - Localize language: In the OpenWeatherMap node’s language field, change “en” to another language code (e.g., “de” for German).
- Expand response details: In Create Response, add more JSON fields like humidity (
{{$json["main"]["humidity"]}}) to enrich the weather report.
Troubleshooting 🔧
Problem: “Webhook not triggering on incoming GET requests.”
Cause: Incorrect webhook path or HTTP method.
Solution: Double-check the webhook node’s path and ensure you use GET method. Test with curl or Postman to confirm.
Problem: “OpenWeatherMap API returning errors or no data.”
Cause: Missing or invalid API key, or malformed city name.
Solution: Verify your API key in the node credentials and ensure city names follow API standards.
Problem: “Response text is empty or incorrect.”
Cause: Using wrong JSON field paths in Create Response node.
Solution: Inspect OpenWeatherMap node JSON output and adjust Set node fields accordingly.
Pre-Production Checklist ✅
- Verify your OpenWeatherMap API key is active and has quota left.
- Test webhook URL with multiple city parameter variations.
- Check n8n workflow is activated before testing.
- Confirm the Set nodes correctly extract and map data fields.
- Test the final response for correct formatting and meaningful content.
Deployment Guide
To deploy, activate the workflow in your n8n instance and share the webhook URL with your users or integrate it into your web app. You can monitor incoming requests and responses directly in n8n’s execution logs for debugging.
If self-hosting n8n online, ensure your server is publicly accessible to receive webhook calls.
FAQs
Q: Can I use a POST method instead of GET for this webhook?
A: This workflow is designed for GET requests with query parameters. You can adjust the webhook node method to POST but must adapt how city data is extracted.
Q: Will calling the OpenWeatherMap API frequently cost me?
A: OpenWeatherMap offers free tier limits; frequent calls beyond that require a paid plan.
Q: Is my API key safe in n8n?
A: API keys are stored securely in n8n credentials and not exposed publicly.
Conclusion
By building this simple yet powerful n8n workflow, Julia now automates real-time weather updates from user input with zero coding beyond the workflow configuration. It saves her countless hours while improving user satisfaction through immediate, accurate weather information. Whether you want to enhance a travel site, chatbot, or mobile app, this automation is a perfect starter to integrate live data dynamically and effortlessly.
Next steps could include adding multi-language support, integrating weather notifications via email or messaging apps, or logging requests for analytics — all achievable with n8n’s extensible automation framework.