1. Opening Problem Statement
Meet Sarah, a project manager at an event planning company. Every morning, Sarah spends nearly 15 minutes searching for accurate weather forecasts to plan outdoor activities, sending updates manually to her team via Slack. This repetitive task not only wastes valuable time but also risks delays if the forecast information is missed or shared late. With weather conditions changing rapidly, Sarah needs a reliable, automated way to get detailed weather updates directly into her team’s Slack channel, ensuring everyone is prepared without the hassle of manual searches.
2. What This Automation Does
This n8n workflow transforms how Sarah obtains and shares weather forecasts, fully automating the process from location input to Slack notification. When triggered by a Slack message, it:
- Receives a location query from Slack via a webhook.
- Uses OpenStreetMap’s Nominatim API to geocode the location text into latitude and longitude.
- Queries the National Weather Service (NWS) API to obtain grid-specific point data based on the geocode.
- Fetches detailed weather forecasts for the location’s grid using the NWS forecast API.
- Formats and posts the forecast data neatly into a specified Slack channel using the Slack node.
With this automation, Sarah saves an estimated 15 minutes daily and eliminates errors due to manual copying or delays, ensuring her team gets current weather insights fast.
3. Prerequisites ⚙️
- n8n account with Workflow Editor access.
- Slack OAuth2 app credentials configured with permissions to post messages in a Slack channel 📧.
- Internet access to call OpenStreetMap and National Weather Service APIs 🔌.
- Webhook configured in n8n to receive location text input.
- Optional: self-hosting option for n8n (Learn more).
4. Step-by-Step Guide to Building the Weather via Slack Workflow
Step 1: Create a Webhook to Receive Location Input
Navigate to Credentials → Nodes → Add Node and select Webhook.
Configure the webhook with these settings:
- HTTP Method: POST
- Path:
slack1(or your preferred endpoint)
Save and activate the webhook. You should see the webhook URL generated, which you will use to send location data from Slack.
Common mistake: Forgetting to activate the webhook will prevent the workflow from triggering.
Step 2: Add HTTP Request Node for OpenStreetMap Geocoding
Click + → Add an HTTP Request node and name it OpenStreetMap.
Configure with:
- Method: GET
- URL:
https://nominatim.openstreetmap.org/search - Query Parameters:
- q:
{{ $('Webhook').item.json.body.text }}(this dynamically injects the location text from the webhook) - format:
json - Headers: User-Agent set to your email or identifier (e.g.,
alexk1919 ([email protected])) to meet API requirements.
Test the node by running it with sample data; expect latitude and longitude in the JSON response.
Common mistake: Not setting the User-Agent header can cause API requests to fail.
Step 3: Add NWS Point Data HTTP Request
Add another HTTP Request node named NWS.
Configure with:
- Method: GET
- URL Template:
https://api.weather.gov/points/{{ $json.body[0].lat }},{{ $json.body[0].lon }} - Headers: Set User-Agent exactly as step 2
This turns latitude and longitude from OpenStreetMap into a weather grid reference.
Common mistake: Incorrectly referencing the latitude and longitude JSON path.
Step 4: Fetch the Weather Forecast for the Location Grid
Add yet another HTTP Request named NWS1.
Set it up to GET forecast data with this dynamic URL:
https://api.weather.gov/gridpoints/{{$json["data"] ? JSON.parse($json["data"]).properties.gridId : ""}}/{{$json["data"] ? JSON.parse($json["data"]).properties.gridX : ""}},{{$json["data"] ? JSON.parse($json["data"]).properties.gridY : ""}}/forecastMake sure to set the User-Agent header again.
After execution, this node returns detailed weather forecasts for multiple periods.
Common mistake: Formatting the URL carefully especially handling the JSON parse expressions.
Step 5: Post the Forecast to Slack
Add a Slack node next.
Set it to post in your desired channel (e.g., channel ID C0889718P8S).
Configure the Text field with this expression to nicely format the forecast for Slack:
{{
JSON.parse($node["NWS1"].json.data).properties.periods
.map(period =>
`*${period.name}*n` +
`Temp: ${period.temperature}°${period.temperatureUnit}n` +
`Wind: ${period.windSpeed} ${period.windDirection}n` +
`Forecast: ${period.shortForecast}`
)
.join("nn")
}}
Authenticate with your Slack OAuth2 credentials.
Common mistake: Forgetting to use the JSON.parse function on nested data causes errors in formatting.
5. Customizations ✏️
- Change Slack Channel: In the Slack node, update
channelIdto your team’s channel ID to send forecasts where you want. - Adjust Forecast Details: Modify the JavaScript map function inside the Slack text parameter to include humidity, chances of rain, or other forecast attributes from the NWS API response.
- Add Location Validation: Insert a decision node before OpenStreetMap to verify if location text is not empty or matches expected formats to reduce erroneous API calls.
- Enable Daily Scheduled Reports: Replace the Webhook with a Schedule Trigger node to automatically send forecasts daily at a set time.
6. Troubleshooting 🔧
Problem: “Failed to fetch data from NWS API”
Cause: Incorrect latitude/longitude input or malformed URL.
Solution: Verify JSON path mappings in NWS HTTP node and test with known coordinates via manual API calls.
Problem: “Slack message not posted”
Cause: OAuth2 token expired or incorrect channel ID.
Solution: Renew Slack OAuth2 credentials under n8n credentials, confirm channel ID from Slack client.
Problem: “Webhook not triggering”
Cause: Webhook inactive or URL changed.
Solution: Reactivate webhook, verify webhook path and method match Slack messaging trigger.
7. Pre-Production Checklist ✅
- Test webhook with sample location input in JSON.
- Verify OpenStreetMap API response includes latitude/longitude.
- Confirm NWS grid point API returns valid JSON with grid data.
- Run NWS forecast node to check multiple period forecasts.
- Send test message to Slack channel with forecast output formatting.
- Ensure OAuth2 credentials for Slack are current and functioning.
8. Deployment Guide
Activate this workflow in n8n and keep it running either on n8n cloud or your self-hosted server.
Integrate the webhook URL with your Slack commands or external apps where users type location queries.
Monitor workflow executions in n8n’s execution log for errors or downtime.
9. FAQs
Q: Can I use a different weather API instead of NWS?
Yes, but you would need to adjust HTTP request nodes accordingly to handle different URL structures and response formats.
Q: Does this workflow consume API credits?
The APIs used (OpenStreetMap and NWS) are free with generous rate limits, but check their policies to avoid limits.
Q: Is my data secure using this workflow?
Yes, all communication is over HTTPS, and Slack tokens are securely stored in n8n credentials.
Q: Can this handle multiple location queries simultaneously?
Yes, n8n can handle multiple webhook triggers concurrently given sufficient system resources.
10. Conclusion
By building this Weather via Slack automation, you have enabled real-time, accurate weather forecasts delivered directly into your Slack workspace triggered by simple location inputs. This saves you or your team up to 15 minutes daily of manual weather lookups and ensures timely planning based on current conditions.
Next, consider extending this workflow to include alerts for severe weather, adding support for multiple languages, or integrating other communication tools like Microsoft Teams.
With n8n and this workflow, you gain powerful automation that keeps your team informed effortlessly.