Tutorial 1: Build Your First n8n Workflow
Build a complete weather notification workflow from scratch. This hands-on tutorial will teach you n8n fundamentals by creating something useful and real.
Duration: 45 minutes Difficulty: Beginner Prerequisites: n8n installed (Docker or npm)
Table of Contents
- What You'll Build
- Prerequisites
- Part 1: Setup & Installation
- Part 2: Create Your First Workflow
- Part 3: Add Schedule Trigger
- Part 4: Fetch Weather Data
- Part 5: Transform the Data
- Part 6: Send Notification
- Part 7: Test & Debug
- Part 8: Activate Your Workflow
- Troubleshooting
- Next Steps
What You'll Build
You'll create an automated weather notification system that:
- ✅ Runs automatically every morning at 8 AM
- ✅ Fetches current weather from OpenWeatherMap API
- ✅ Formats data into a readable message
- ✅ Sends notification to Slack (or email)
- ✅ Handles errors gracefully
Final Output Example:
What You'll Learn:
- n8n interface navigation
- Creating and connecting nodes
- Working with HTTP requests
- Data transformation with Code nodes
- Scheduling workflows
- Credential management
- Testing and debugging
- Activating workflows
Prerequisites
Required
1. n8n Running Locally
Choose one method:
Option A: Docker (Recommended)
Option B: npm
Verify by visiting http://localhost:5678 in your browser.
2. Free OpenWeatherMap API Key
- Sign up at openweathermap.org
- Get free API key (Current Weather Data API)
- Note: API may take 10-20 minutes to activate
3. Slack Workspace (Optional)
- For Slack notifications: Admin access to create webhooks
- Alternative: Use Email node instead (Gmail, Outlook, etc.)
Optional but Helpful
- Basic understanding of JSON
- Familiarity with APIs (we'll explain everything)
Part 1: Setup & Installation
Step 1.1: Verify n8n is Running
- Open browser to
http://localhost:5678 - You should see the n8n interface
- If first time, create owner account:
- Email: your-email@example.com
- Password: (secure password)
Step 1.2: Familiarize with Interface
Take 2 minutes to explore:
Left Panel: Search for nodes Center Canvas: Where you build workflows Right Panel: Node settings (when node selected) Top Bar: Workflow controls (Execute, Save, Activate)
Step 1.3: Get Your API Keys Ready
OpenWeatherMap:
- Login to OpenWeatherMap account
- Go to API Keys section
- Copy your API key
- Keep handy for Step 4
Slack (Optional):
- Go to
api.slack.com/apps - Create new app
- Add "Incoming Webhooks"
- Copy webhook URL
Part 2: Create Your First Workflow
Step 2.1: Create New Workflow
- Click "New Workflow" (+ icon top left)
- You'll see an empty canvas
- Click workflow name (top left) and rename to:
Weather Notification
Step 2.2: Add a Sticky Note (Documentation)
Let's document our workflow:
- Right-click on canvas
- Select "Add Sticky Note"
- Add this text:
Good practice: Always document workflows!
Part 3: Add Schedule Trigger
Workflows need a trigger to start. We'll use a schedule trigger.
Step 3.1: Add Schedule Trigger Node
- Click anywhere on canvas
- Search for "Schedule Trigger"
- Click to add it
You'll see the node appear with settings panel on right.
Step 3.2: Configure the Schedule
In the right settings panel:
- Trigger Interval: Select "Days"
- Days Between Triggers: Enter
1(daily) - Trigger Time: Set to
08:00 - Trigger at Day Start: Keep default
Your workflow will now run every day at 8 AM.
Step 3.3: Test the Trigger
- Click "Execute Node" button (on the trigger)
- You should see green checkmark ✓
- Bottom panel shows execution time
- This confirms trigger works!
💡 Tip: "Execute Node" tests individual nodes manually.
Part 4: Fetch Weather Data
Now let's get weather data from OpenWeatherMap API.
Step 4.1: Add HTTP Request Node
- Click the + button on the right side of Schedule Trigger
- Search for "HTTP Request"
- Select the node
Step 4.2: Configure API Request
In the HTTP Request settings:
Authentication: None (we'll use API key in URL)
Method: GET
URL:
Query Parameters:
Add these parameters (click "Add Parameter"):
| Name | Value |
|---|---|
| q | San Francisco |
| appid | YOUR_API_KEY_HERE |
| units | imperial |
Replace YOUR_API_KEY_HERE with your actual OpenWeatherMap API key.
What these parameters do:
q: City name (you can change to your city)appid: Your API authentication keyunits: imperial (Fahrenheit) or metric (Celsius)
Step 4.3: Test the API Call
- Click "Execute Node"
- Wait a few seconds
- Check bottom panel - you should see JSON response
- Expand the data to see weather information
Expected Response Structure:
Step 4.4: Understanding the Data
Look at the JSON response in the output panel. Key fields:
name: City namemain.temp: Temperaturemain.feels_like: Feels like temperaturemain.humidity: Humidity percentageweather[0].description: Weather descriptionwind.speed: Wind speed
We'll use these in the next step!
Part 5: Transform the Data
Raw JSON isn't user-friendly. Let's format it nicely.
Step 5.1: Add Code Node
- Click + after HTTP Request node
- Search for "Code"
- Select the node
Step 5.2: Write Transformation Code
In the Code editor, replace everything with:
Step 5.3: Understanding the Code
Line-by-line explanation:
$input.first(): Gets data from previous node (HTTP Request).json: Accesses the JSON data
data.main.temp: Temperature from API responseMath.round(): Rounds to nearest integer
- Template literal (backticks) for multi-line string
${variable}: Inserts variable values
- Returns data in n8n format (array of objects with
jsonproperty)
Step 5.4: Test the Transformation
- Click "Execute Node"
- View output in bottom panel
- You should see the formatted message
Expected Output:
Perfect! Now we have a nicely formatted message.
Part 6: Send Notification
Final step: Send the message to Slack (or email).
Option A: Slack Notification
Step 6.1: Add Slack Node
- Click + after Code node
- Search for "Slack"
- Select "Slack" node (not Slack Trigger)
Step 6.2: Configure Slack Connection
Authentication:
- Click "Create New Credential"
- Select "Slack OAuth2 API"
- Follow OAuth flow to connect your Slack workspace
- Authorize n8n access
OR use Webhook (simpler):
- In Slack node, select "Post Message" operation
- Instead of OAuth, use Webhook URL in credential
- Get webhook URL from
api.slack.com/apps> Incoming Webhooks
Step 6.3: Configure Message
Resource: Message Operation: Post
Channel: #general (or create #weather channel)
Text (Expression Mode):
This uses the formatted message from the Code node!
Option B: Email Notification (Alternative)
If you prefer email over Slack:
Step 6.1: Add Email Node
- Click + after Code node
- Search for "Email" or "Gmail"
- Select "Gmail" (or SMTP for other email)
Step 6.2: Configure Email
Subject:
Email Type: Text
Text:
From Email: your-gmail@gmail.com
Authentication:
- Connect Gmail via OAuth2
- Or use App Password for SMTP
Step 6.4: Test the Notification
- Click "Execute Node" on Slack/Email node
- Check Slack channel or email inbox
- You should receive the formatted weather message!
Part 7: Test & Debug
Step 7.1: Test Complete Workflow
Now let's test the entire workflow end-to-end:
- Click "Execute Workflow" button (top bar)
- Watch each node execute in sequence:
- Schedule Trigger ✓
- HTTP Request ✓
- Code ✓
- Slack/Email ✓
- Check that notification was received
All nodes should have green checkmarks!
Step 7.2: Inspect Node Data
Click on each node to see data flow:
HTTP Request Node:
- Click on node after execution
- View "Output" tab
- See raw API response
Code Node:
- View "Input" tab: See data from HTTP Request
- View "Output" tab: See formatted message
This helps you understand data transformation!
Step 7.3: Common Issues & Fixes
Issue: HTTP Request fails with 401 error
- Fix: Check API key is correct
- Fix: Ensure API key is activated (wait 10-20 minutes after signup)
Issue: Slack notification not received
- Fix: Verify channel name is correct (include #)
- Fix: Check bot has permission to post in channel
- Fix: Re-authenticate Slack credential
Issue: Code node errors
- Fix: Check syntax (missing brackets, quotes)
- Fix: Verify variable names match API response
- Fix: Add console.log() to debug:
Issue: Message formatting looks wrong
- Fix: Check template literal backticks (not quotes)
- Fix: Ensure line breaks (\n) are preserved
Part 8: Activate Your Workflow
Step 8.1: Save the Workflow
- Click "Save" button (top right)
- Confirm workflow name: "Weather Notification"
- Green toast notification confirms save
Step 8.2: Activate Workflow
- Click the toggle switch at top right: "Active"
- It should turn blue/green indicating active
- Workflow will now run automatically every day at 8 AM!
Step 8.3: Monitor Executions
View workflow runs:
- Click "Executions" in left sidebar
- See list of all workflow runs
- Click any execution to see details
- Check for errors or successes
Set up notifications for failures:
- Go to Workflow Settings
- Set "Error Workflow" to send alerts on failure
Step 8.4: Test Schedule (Optional)
To test without waiting until 8 AM:
- Deactivate workflow temporarily
- Change schedule to run in 2 minutes
- Activate and wait
- Check notification arrives
- Change schedule back to 8 AM
Troubleshooting
Problem: Workflow doesn't trigger at scheduled time
Diagnose:
- Is workflow Active (toggle on)?
- Check timezone settings (Workflow Settings)
- Review execution history for errors
Solutions:
Problem: API returns empty data
Diagnose:
- Test API in browser/Postman
- Check API key is valid
- Verify city name is correct
Solutions:
- Use city ID instead of name:
id=5391959for San Francisco - Check API documentation: openweathermap.org/current
- Try different city name format: "San Francisco,US"
Problem: Code node errors
Common Error: Cannot read property 'temp' of undefined
Solution:
Debugging technique:
View logs:
Problem: Notification not formatted correctly
Issue: Message shows escaped characters like \n
Solution: Use Slack blocks or ensure email client supports plain text formatting
Alternative Slack formatting:
Enhancing Your Workflow
Enhancement 1: Add Error Handling
Create Error Workflow:
-
Create new workflow: "Weather Error Handler"
-
Add nodes:
-
In main workflow:
- Settings → Error Workflow
- Select "Weather Error Handler"
Error notification code:
Enhancement 2: Multiple Cities
Modify to send weather for multiple cities:
-
After Schedule Trigger, add "Code" node:
-
Update HTTP Request URL parameter:
- Change
qfrom "San Francisco" to={{ $json.city }}
- Change
Now workflow loops through all cities!
Enhancement 3: Weather Alerts
Add conditional logic:
- After Code node (formatting), add "IF" node
- Condition:
- Route "true" to urgent alert (SMS, phone call)
- Route "false" to regular Slack message
Enhancement 4: Store Weather History
Track weather over time:
- Add "Google Sheets" or "PostgreSQL" node
- After Code node, branch to database
- Store: date, city, temp, conditions
Later, analyze trends!
Key Concepts Learned
✅ Nodes & Connections
- Nodes are building blocks of workflows
- Connections pass data between nodes
- Green checkmarks indicate success
✅ Triggers
- Schedule Trigger: runs on cron schedule
- Other triggers: Webhook, Manual, Email, etc.
- Active workflows run automatically
✅ Data Flow
$input: Access data from previous node$json: The JSON payload$node["Name"]: Access specific node data
✅ Expressions
={{ ... }}: Expression mode- Access dynamic data in fields
- JavaScript expressions allowed
✅ Code Nodes
- Full JavaScript/Python environment
- Transform data with custom logic
return [{ json: {...} }]: Return format
✅ HTTP Requests
- Connect to any REST API
- Query parameters, headers, authentication
- GET, POST, PUT, DELETE methods
✅ Debugging
- Execute individual nodes
- Inspect input/output data
- View execution history
- Check logs for errors
Next Steps
Congratulations! 🎉
You've built your first n8n workflow! You now understand:
- n8n fundamentals
- API integration
- Data transformation
- Scheduling
- Notifications
Continue Learning
Recommended Next Steps:
-
Modify this workflow:
- Change to your city
- Add more weather details
- Try different notification channels
-
Build a variation:
- Stock price alerts
- News digest
- RSS feed aggregator
- Exchange rate monitor
-
Complete Tutorial 2:
- Data Pipeline Automation
- Learn databases, batching, error handling
- Build production-ready workflows
-
Explore Use Cases:
- Use Cases Guide
- Find workflows for your industry
- Apply patterns to your needs
-
Read Best Practices:
- Best Practices Guide
- Learn professional patterns
- Production deployment tips
Project Ideas (Practice)
Build these workflows to practice:
Easy:
- Daily motivational quote
- RSS to email digest
- GitHub stars tracker
- Currency converter alert
Medium:
- Form submission to database
- Customer email automation
- Social media cross-posting
- Backup automation
Challenging:
- Multi-source data aggregation
- Event-driven workflows
- Complex approval flows
- Integration hub for multiple apps
Workflow Export
Download this workflow:
[Export JSON link would go here]
Import it to compare with your build!
To import:
- Workflows → Import from File
- Select downloaded JSON
- Review and compare
Additional Resources
Official n8n Resources
Related Guides
APIs to Explore
Get Help
Stuck? Have questions?
- Community Forum: community.n8n.io
- Discord: Active community for quick questions
- Documentation: docs.n8n.io
Found this tutorial helpful? Share it with others learning n8n!
Need personalized help? Contact me about 1-on-1 tutoring or team training.
→ Ready for more? Continue to Tutorial 2: Data Pipeline Automation
Happy automating! 🚀