Overview
In this lesson, you'll get a clear introduction to n8n, a powerful open-source automation platform. You’ll learn why n8n stands out among automation tools and build a simple workflow that automatically saves Gmail attachments to Google Drive and notifies your team on Discord. This hands-on tutorial will familiarize you with core n8n concepts such as nodes, triggers, and data filtering, setting a solid foundation for creating advanced automations.
What is n8n and Why Use It?
n8n (pronounced "n-eight-n") is a source-available automation platform designed to connect hundreds of applications, allowing you to automate workflows without writing code. It supports building complex workflows with conditional logic, data transformation, and even AI integration.
Three Key Advantages of n8n
Workflow-based Pricing
Unlike other tools (e.g., Zapier, Make.com) that charge per task or operation, n8n charges per workflow execution. This means you can run complex workflows with hundreds of steps at a predictable cost, making budgeting easier and more cost-effective.Full Control and Flexibility
You can self-host n8n on your local machine, cloud, or use the enterprise/cloud versions. This eliminates vendor lock-in, giving you full control over your data and business logic. If you want to get started quickly, check out how to install n8n via npm/Node.js.Support for Complex Workflows
n8n supports advanced conditional logic, data splitting, merging, and transformation. It also offers code and HTTP nodes, enabling custom scripting and API integrations, perfect for AI-powered automations and sophisticated business processes.
How n8n Compares to Other Automation Tools
- Cost Efficiency: Other tools charge per task or step, which can get expensive for complex workflows.
- Handling Complex Business Logic: n8n excels at integrating external databases and APIs for complex workflows.
- Avoiding Vendor Lock-in: You can self-host n8n, unlike many cloud-only platforms.
Thousands of developers and businesses are adopting n8n to scale their automation efficiently and securely. For a detailed comparison, see the n8n vs Zapier vs Make.com Comparison.
For more details, check the official n8n documentation: About n8n.
Core Concepts: Nodes and Workflows in n8n
What is a Workflow?
A workflow in n8n is a sequence of connected nodes that work together to automate a process.
What are Nodes?
Nodes are individual steps in a workflow. Each node performs a specific task such as:
- Triggering the workflow (e.g., when an email arrives)
- Transforming or filtering data
- Sending messages or saving files
Think of nodes as workers on an assembly line, each doing their part and passing data to the next.
Node Categories
- Trigger Nodes: Start the workflow based on an event (e.g., new Gmail email, scheduled time).
- Data Transformation Nodes: Filter, route, or modify data.
- Action Nodes: Perform final tasks like sending notifications or saving files.
To understand these better, explore the n8n Node Types Explained lesson.
Building Your First n8n Workflow: Auto-saving Gmail Attachments
In this hands-on example, you will build a workflow to:
- Listen for incoming Gmail emails (trigger)
- Check if the emails have attachments (filter)
- Save attachments to Google Drive (action)
- Notify your team on Discord (action)
Step 1: Mapping the Business Process
Before building the workflow, map out the process in simple terms:
- Trigger: New email arrives in Gmail inbox
- Condition: Email contains attachments
- Action 1: Upload attachment to Google Drive folder
- Action 2: Send notification message to Discord channel
This generic mapping allows you to replace apps/services later if needed.
Step 2: Accessing n8n Interface
You can use n8n Cloud or self-host n8n locally. For this tutorial, the cloud version is used, but setup instructions for local installation can be found in the official docs: Installing n8n. You can also refer to the Install n8n via npm/Node.js lesson for a step-by-step guide.
Step 3: Adding Nodes to Your Workflow
3.1 Add Gmail Trigger Node
- Use the
Gmail Triggernode to listen for new emails. - Configure it to watch your inbox.
- This node outputs email data including attachments.
3.2 Add Filter Node
- Add a
IForFilternode to check if the incoming email has attachments. - Use an expression to check for the presence of binary data (attachments).
Example expression to check if an attachment exists:
{{ $json["binary"] !== undefined }}
If the condition is true, the workflow continues; otherwise, it stops.
3.3 Add Google Drive Node
- Add a
Google Drivenode to upload files. - Select your Google Drive credentials (create or reuse).
- Operation:
Upload - Specify the target folder (e.g., "Hands-on Labs").
- Map the attachment from the previous node as the file to upload.
- You can customize the uploaded file name using expressions, for example:
{{ $json["messageId"] }}_uploaded_file_name
3.4 Add Discord Node
- Add a
Discordnode to send a notification message. - Use your Discord credentials and select the channel.
- Compose a message like:
Attachment saved successfully for the email: {{ $json["subject"] }}
For more details on the Merge node and other node types, see the n8n Merge node documentation.
Step 4: Testing the Workflow
- Click the
Test Workflowbutton in the n8n interface. - The workflow will fetch the latest email, check for attachments, upload the file, and send a Discord message.
Verify:
- File appears in the Google Drive folder.
- Discord channel receives the notification.
- No errors occur during execution.
Understanding Node Inputs and Outputs
Each node processes data passed from the previous node. You can inspect this data in the node’s panel:
- Input data: What the node receives.
- Output data: What the node sends to the next step.
For example, the Gmail trigger outputs data with properties like:
id(email ID)subjecttext(email body)binary(attachments)
You can view this data in JSON or table formats to understand the structure.
Expressions in n8n
Expressions allow you to dynamically access data from previous nodes. They use the syntax:
{{ $node["Node Name"].json["propertyName"] }}
Or shorthand:
{{ $json["propertyName"] }}
You’ll use expressions to:
- Check if attachments exist
- Name uploaded files dynamically
- Build notification messages
The course will cover expressions in detail later.
Common Mistakes and Troubleshooting
No Triggered Emails:
Ensure your Gmail credentials are properly connected and the trigger node is configured to listen to the correct inbox or label.Attachments Not Detected:
Verify the filter expression is correctly checking forbinarydata. Use test runs to inspect incoming data formats.Google Drive Upload Fails:
Check credentials and ensure the target folder exists. Verify upload permissions.Discord Notification Not Sent:
Ensure webhook or bot credentials are correct and the channel ID is properly set.Hardcoded File Names:
Avoid hardcoding file names if multiple attachments may arrive. Use expressions and additional nodes (likeSplitInBatches) to handle multiple files robustly.
Next Steps in This Course
- Deep dive into each node type and their configuration.
- Learn advanced expression building.
- Explore handling multiple attachments and batch processing.
- Discover how to self-host n8n and manage credentials securely.
- Compare n8n with other automation tools like Zapier and Make.com.
For more information on self-hosting and contributing, visit the official n8n GitHub repository.
Quick Reference Cheat Sheet
| Step | Node Type | Key Settings / Expressions |
|---|---|---|
| Trigger on new email | Gmail Trigger |
Connect Gmail, set label/inbox to monitor |
| Check for attachment | IF or Filter |
Expression: {{ $json["binary"] !== undefined }} |
| Upload attachment | Google Drive |
Operation: Upload, Target folder, File: {{ $json["attachment_0"] }} |
| Send notification | Discord |
Message: Attachment saved for email: {{ $json["subject"] }} |
By following this tutorial, you’ve built your first n8n automation workflow that saves Gmail attachments to Google Drive and notifies your team on Discord. This foundational knowledge prepares you to explore more complex workflows and integrations in the upcoming lessons. For a complete guide on nodes and workflows, visit the official docs: n8n Workflow Basics.