How to Automate Gmail with n8n (Complete Step-by-Step Guide)

Affiliate Disclosure: Some links on this page are affiliate links. We may earn a commission at no extra cost to you. We only recommend tools we personally use and trust.

Why Automate Your Email?

The average professional spends 28% of their workday reading and responding to emails. That translates to roughly 2.6 hours per day or over 13 hours per week buried in your inbox. For many of us, a significant portion of that time goes toward repetitive, predictable tasks: forwarding certain emails to team members, saving attachments, logging information in spreadsheets, or sending templated replies.

What if you could reclaim even half of that time? That is exactly what email automation delivers. By setting up intelligent workflows that handle repetitive email tasks automatically, you can focus your energy on work that actually requires human creativity and judgment.

n8n is one of the most powerful tools for email automation because it is open-source, self-hostable, and offers deep integration with Gmail through its native nodes. Unlike simpler tools that only support basic rules, n8n lets you build complex, multi-step workflows that connect Gmail to hundreds of other applications, including Slack, Google Sheets, Notion, Trello, databases, and custom APIs.

In this tutorial, you will build a complete Gmail automation workflow from scratch. By the end, you will have a fully functional system that triggers on incoming emails, applies intelligent filters, and executes actions automatically. No coding required.

Prerequisites

Before we begin, make sure you have the following ready:

  • An n8n account — either a free n8n Cloud account or a self-hosted instance (we will cover both options below)
  • A Gmail account — any personal or Google Workspace account will work
  • A Google Cloud Console project — for creating OAuth2 credentials (free)
  • About 10–15 minutes — that is all it takes to set up your first automated workflow

No programming experience is needed. If you can drag and drop, you can build these automations.

Step 1: Set Up n8n

You have two options for running n8n: Cloud-hosted or self-hosted. Each approach has distinct advantages.

A

n8n Cloud (Easiest)

The fastest way to get started is with n8n Cloud. Sign up for a free account, verify your email, and you will have a fully managed n8n instance ready in under two minutes.

Advantages of n8n Cloud:

  • No server setup or maintenance required
  • Automatic updates to the latest version
  • Built-in SSL and security
  • Available from any device with a browser
B

Self-Hosted with Docker

If you prefer full control over your data and want unlimited executions, you can self-host n8n using Docker.

docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  n8nio/n8n

This command pulls the latest n8n Docker image and starts it on port 5678. Open http://localhost:5678 in your browser and create your owner account. Your workflow data is persisted in the n8n_data Docker volume, so it survives container restarts.

For production use, you should run n8n behind a reverse proxy (like Nginx or Caddy) with HTTPS, especially if you plan to use OAuth2 callbacks for Gmail authentication.

Step 2: Create a New Workflow

Once you are logged into n8n (Cloud or self-hosted), follow these steps:

  1. Click the "New Workflow" button in the top right corner, or press Ctrl+N
  2. Give your workflow a descriptive name by clicking the default name at the top, for example: "Gmail Inbox Automation"
  3. You will see an empty canvas with a Start node. This is your workflow builder where you will drag, drop, and connect nodes to create your automation logic

The n8n canvas works like a visual flowchart. Data flows from left to right, passing through each node in sequence. Each node performs a specific action: reading emails, filtering data, sending messages, writing to databases, and so on. You connect nodes by dragging a line from one node's output to the next node's input.

Step 3: Add the Gmail Trigger Node

The Gmail Trigger node watches your inbox for new emails and kicks off your workflow whenever a matching email arrives.

3a. Add the Node

  1. Click the "+" button on the canvas or press Tab to open the node search panel
  2. Type "Gmail Trigger" and select it from the results
  3. The node configuration panel will open on the right side

3b. Configure Gmail OAuth2 Credentials

This is the most important step. n8n needs permission to access your Gmail account via OAuth2. Here is how to set it up:

  1. In the Gmail Trigger node, click "Create New Credential" under the Authentication field
  2. Go to the Google Cloud Console
  3. Create a new project (or select an existing one)
  4. Navigate to APIs & Services > Library and enable the Gmail API
  5. Go to APIs & Services > Credentials and click "Create Credentials" > "OAuth Client ID"
  6. Select "Web application" as the application type
  7. Under "Authorized redirect URIs", add the redirect URL shown in n8n's credential configuration panel. For n8n Cloud, it will look like https://app.n8n.cloud/rest/oauth2-credential/callback. For self-hosted, it will be https://your-domain.com/rest/oauth2-credential/callback
  8. Copy the Client ID and Client Secret from Google Cloud Console into the corresponding fields in n8n
  9. Click "Sign in with Google" in n8n and authorize the connection

Important: If your Google Cloud project is in "Testing" mode, you need to add your Gmail address as a test user under the OAuth consent screen settings. Otherwise, the authorization will fail.

3c. Configure the Trigger

In the Gmail Trigger node settings:

  • Poll Times: Set how often n8n checks for new emails. Every 1 minute is a good default. On n8n Cloud, the minimum is typically every 2 minutes on the free plan
  • Filters: You can optionally filter by label (e.g., INBOX), read status, or include/exclude specific labels
  • Simple Output: Enable this to get a clean data structure with fields like from, to, subject, body, and date

Step 4: Add Filter Conditions

Raw email triggers fire on every incoming email. You need filters to target only the emails that matter. Add an IF node (or Switch node for multiple conditions) after the Gmail Trigger:

  1. Click the "+" on the Gmail Trigger node's output
  2. Search for "IF" and add it
  3. Configure your conditions. Common examples:
  • Filter by sender: from contains @important-client.com
  • Filter by subject keywords: subject contains invoice or urgent
  • Filter by attachment presence: hasAttachment equals true
  • Filter by recipient (CC): to contains team@yourcompany.com

The IF node has two outputs: true (condition matched) and false (condition not matched). Connect different action nodes to each output to handle both cases. For more complex routing, use the Switch node, which supports multiple conditions with multiple outputs.

You can also chain multiple IF nodes in sequence to create sophisticated filtering logic. For instance, first check the sender, then check the subject line, then check for attachments, each level narrowing down to more specific actions.

Step 5: Add Action Nodes

This is where the real power of automation comes in. After filtering, you can connect any combination of action nodes. Here are the three most popular actions for Gmail automation:

Action A: Send a Slack Notification

  1. Add a Slack node after the IF node's "true" output
  2. Connect your Slack workspace using OAuth2 (similar process to Gmail)
  3. Choose "Send Message" as the action
  4. Select the target channel (e.g., #email-alerts)
  5. In the message body, use n8n expressions to include email data:
    New email from: {{ $json.from }}
    Subject: {{ $json.subject }}
    Preview: {{ $json.snippet }}

This way, your team gets instant Slack alerts for important emails without anyone needing to monitor the inbox manually.

Action B: Log to Google Sheets

  1. Add a Google Sheets node
  2. Connect your Google account and select a spreadsheet
  3. Choose "Append Row" as the operation
  4. Map email fields to spreadsheet columns:
    • Column A (Date): {{ $json.date }}
    • Column B (From): {{ $json.from }}
    • Column C (Subject): {{ $json.subject }}
    • Column D (Status): New

This creates an automatic email log, perfect for tracking client communications, support requests, or sales inquiries.

Action C: Send an Auto-Reply

  1. Add a Gmail node (not the trigger, the regular Gmail action node)
  2. Select "Send Email" or "Reply to Email" as the operation
  3. Set the "To" field using the incoming email's sender: {{ $json.from }}
  4. Write your auto-reply template:
    Hi,
    
    Thank you for your email. I've received your message regarding "{{ $json.subject }}" and will respond within 24 hours.
    
    Best regards

Warning: Be careful with auto-replies. Add strict filters to prevent reply loops (e.g., exclude emails from noreply@ addresses, exclude your own email address, and add a condition that only triggers once per sender per day).

Step 6: Test and Activate

Before going live, test your workflow thoroughly:

  1. Manual Test: Click "Execute Workflow" in the top right. n8n will fetch recent emails from your inbox and run them through your entire workflow. Inspect the output of each node to verify the data looks correct
  2. Check Each Node: Click on any node to see what data it received (input) and what it produced (output). Fix any mapping errors
  3. Send a Test Email: Send yourself an email that matches your filter conditions and verify the entire chain executes correctly
  4. Activate: Once everything works, toggle the "Active" switch in the top right corner. The workflow is now running continuously in the background

After activation, you can monitor workflow executions from the "Executions" tab in n8n. This shows a history of every run, including any errors. Set up error notifications (n8n supports email and webhook notifications on error) so you know immediately if something breaks.

3 Complete Workflow Examples

Example 1: Auto-Label and Forward Important Emails

This workflow automatically categorizes incoming emails and forwards high-priority messages to the right team member.

Workflow structure:

Gmail Trigger
  → Switch Node (check sender domain)
    → Branch 1: Client emails (@client.com)
        → Gmail: Add label "Client"
        → Gmail: Forward to account-manager@yourcompany.com
    → Branch 2: Support emails (subject contains "help" or "issue")
        → Gmail: Add label "Support"
        → Slack: Post to #support-queue
    → Branch 3: Newsletter/marketing
        → Gmail: Add label "Newsletters"
        → Gmail: Mark as read

This eliminates the daily chore of manually sorting and forwarding emails. The Switch node routes emails into different branches based on your conditions, and each branch applies the appropriate labels and actions.

Example 2: Save Attachments to Google Drive

Automatically extract attachments from incoming emails and organize them in Google Drive folders.

Workflow structure:

Gmail Trigger (filter: has attachment)
  → IF Node (attachment type is PDF, XLSX, or DOCX)
    → True:
        → Google Drive: Upload file to "Email Attachments/{{ $json.from }}"
        → Google Sheets: Log filename, sender, date
        → Gmail: Add label "Attachment Saved"
    → False:
        → No action (skip images, signatures, etc.)

This is particularly useful for accounting teams receiving invoices, HR departments collecting resumes, or anyone who regularly receives important documents via email. The attachments are automatically organized by sender into Google Drive folders, and a spreadsheet log keeps track of everything.

Example 3: Create Tasks from Emails in Notion

Turn emails into actionable tasks in your Notion workspace automatically.

Workflow structure:

Gmail Trigger (filter: label "Action Required")
  → Notion: Create page in Tasks database
      - Title: {{ $json.subject }}
      - From: {{ $json.from }}
      - Date Received: {{ $json.date }}
      - Email Body: {{ $json.body }}
      - Status: "To Do"
      - Priority: (use IF node to set based on sender)
  → Gmail: Mark as read
  → Gmail: Remove "Action Required" label
  → Gmail: Add "Task Created" label

For this workflow, you first apply the "Action Required" label to emails in Gmail (manually or with a Gmail filter). n8n watches for that label, creates a Notion task, and updates the Gmail labels to reflect that the task has been created. This bridges the gap between your inbox and your project management system without any manual data entry.

Troubleshooting Common Issues

OAuth2 Authorization Fails

Problem: You see an error like "Access blocked" or "This app isn't verified" when trying to connect Gmail.

Solution: In Google Cloud Console, go to OAuth consent screen and make sure your email is added as a test user. If you are using a personal project, Google requires this step while the app is in "Testing" mode. You do not need to publish or verify the app for personal use.

Trigger Not Firing

Problem: The workflow is active but never executes.

Solution: Check that the polling interval is set correctly. On n8n Cloud free tier, polling might be limited to every 5 minutes. Also verify that your Gmail filters in the trigger node are not too restrictive. Try removing all filters temporarily to test if the trigger works at all, then add them back one by one.

Duplicate Notifications

Problem: You receive multiple notifications for the same email.

Solution: n8n tracks which emails it has already processed using internal state. If you restart the workflow or the instance, it may re-process recent emails. Add a deduplication step using the Function node or store processed message IDs in a database. Alternatively, after processing an email, have the workflow add a specific Gmail label (like "Processed") and filter out emails with that label in the trigger.

Rate Limiting

Problem: You see errors like "Rate Limit Exceeded" from the Gmail API.

Solution: The Gmail API has a daily limit of approximately 1 billion quota units per day for most projects, but individual operations have per-second limits. If you are processing many emails at once, add a Wait node between Gmail operations (1–2 seconds is usually enough). For high-volume processing, use batch operations where possible.

Attachments Not Downloading

Problem: The Gmail node output does not include attachment data.

Solution: Make sure you enable the "Download Attachments" option in the Gmail Trigger node settings. By default, n8n only fetches email metadata to save bandwidth. Enabling attachment downloads increases data transfer but is necessary for workflows that process or save files.

Start Automating Your Gmail Today

Setting up email automation with n8n takes less than 15 minutes and can save you hours every week.

Try n8n Free Compare n8n vs Zapier

Frequently Asked Questions

Is n8n free to use for Gmail automation?

Yes, n8n offers a free self-hosted option where you can run unlimited workflows on your own server using Docker. The n8n Cloud plan starts free with limited executions, and paid plans begin at around $20/month for higher volume. For personal Gmail automation, the free self-hosted version is more than sufficient.

How do I connect Gmail to n8n with OAuth2?

To connect Gmail to n8n, create OAuth2 credentials in the Google Cloud Console. Enable the Gmail API, create an OAuth2 Client ID for a "Web application," add the n8n redirect URI, and enter the Client ID and Secret in n8n's Gmail credential settings. n8n will then prompt you to authorize access to your Gmail account through a standard Google sign-in flow.

Can I automate Gmail without coding knowledge?

Absolutely. n8n provides a visual drag-and-drop workflow builder that requires zero coding. You connect nodes (Gmail trigger, filters, actions) by drawing lines between them. The entire setup covered in this tutorial can be completed in about 10 minutes with no programming experience whatsoever.

NoCodeFlow Team

NoCodeFlow is dedicated to helping professionals and small businesses automate their workflows without code. We publish in-depth tutorials, tool comparisons, and practical guides covering the best no-code automation platforms, including n8n, Make.com, and Zapier. Our content is based on hands-on testing and real-world usage.

Related Articles

n8n vs Zapier: The Complete Comparison

See how n8n stacks up against Zapier on features, pricing, and flexibility.

7 Best Free Automation Tools in 2026

Discover the top free tools for workflow automation this year.

Automate Social Media Without Code

Learn how to schedule, cross-post, and analyze social media without coding.

Ad Space