How to Build a Google Sheets to Gmail Automation Workflow with n8n (Step-by-Step Guide)

In this tutorial, we will walk through the complete process of building a fully automated email workflow using n8n (self-hosted), Google Sheets, and Gmail. We will cover everything from setting up the Google Cloud OAuth credentials to building and running the workflow on n8n.

This workflow will automatically send personalized emails to new entries added to a Google Sheet.

Overview of What We Will Build
  • Use Google Sheets to collect names, phone numbers, and emails.
  • Whenever a new row is added, automatically send a personalized email using Gmail.
  • Fully automated with no manual intervention.
  • Securely authorized using Google OAuth2 credentials.
  • Runs on your self-hosted n8n instance.
Step 1: Set Up Your Self-Hosted n8n Instance

We assume you have a self-hosted n8n running on a cloud server (like DigitalOcean or any VPS) with SSL properly configured. If not, you can follow our previous guide for setting up n8n using Docker and NGINX with SSL certificates.

Step 2: Create a Google Cloud Project
  1. Go to Google Cloud Console.
  2. Click Select Project > New Project.
  3. Enter a name (e.g., “n8n Automation Project”) and create the project.
Step 3: Enable Required Google APIs

Inside your new Google Cloud project:

  1. Navigate to APIs & Services > Library.
  2. Enable the following APIs:
    • Google Sheets API
    • Google Drive API
    • Gmail API

These APIs allow n8n to access Google Sheets data, Gmail, and handle files under Google Drive (which Sheets is technically part of).

Step 4: Set Up OAuth Consent Screen
  1. Go to APIs & Services > OAuth consent screen.
  2. Choose External for user type.
  3. Fill in the following:
    • App Name: n8n Google Automation
    • User Support Email: your email
    • Developer Contact Info: your email
  4. For Scopes, you can leave blank at first (scopes will be requested automatically during n8n authorization).
  5. In Test Users, add the Gmail accounts that you want to authorize initially (e.g., your own Gmail).

Note: You can only authorize users added here until you submit for verification later.

Step 5: Create OAuth Client ID and Secret
  1. Go to APIs & Services > Credentials.
  2. Click Create Credentials > OAuth Client ID.
  3. Select Web Application.
  4. Enter name: “n8n OAuth Credentials”.
  5. Add Authorized redirect URI:
https://your-n8n-domain.com/rest/oauth2-credential/callback

(Replace your-n8n-domain.com with your actual n8n domain, e.g., agents.chrmp.com)

  1. Click Create.
  2. Copy your Client ID and Client Secret.
Step 6: Prepare Your Google Sheet

Create a new Google Sheet with columns:

NAMEPhone NumberEmail
John Doe9999999999john@example.com

Share this Google Sheet with the same Gmail account that you will authorize via OAuth later.

Step 7: Create Google Sheets OAuth2 Credential in n8n
  1. In your n8n instance, go to Credentials > Create New.
  2. Choose Google Sheets OAuth2.
  3. Enter the Client ID and Client Secret from Step 5.
  4. The Redirect URL field should match what you entered earlier.
  5. Click Connect OAuth Account and authorize access.
Step 8: Create Gmail OAuth2 Credential in n8n
  1. Again, create New Credential > Gmail OAuth2.
  2. Use the same Client ID and Client Secret as before.
  3. Connect and authorize Gmail access.
Step 9: Build The Workflow in n8n
Node 1: Google Sheets Trigger
  • Type: Google Sheets Trigger
  • Spreadsheet ID: (Copy the sheet ID from Google Sheet URL)
  • Sheet Name: e.g., Sheet1
  • Polling Interval: every 5 minutes
Node 2: Gmail Send
  • Type: Gmail
  • Operation: Send
  • Subject:
Welcome {{ $json["NAME"] }}
  • Message:
Hi {{ $json["NAME"] }},

Thank you for submitting your contact information.

We have your phone number as {{ $json["Phone Number"] }}.

We will reach out if needed.

Regards,
Your Team
  • To Email:
={{ $json["Email"] }}
Step 10: Handle Deduplication (Prevent Duplicate Sends)

We can use n8n’s built-in Data Store node for simple deduplication:

  • Create Data Store Get All node before sending email.
  • Add Function Node to check whether $json["Email"] exists inside the stored list.
  • Only proceed to Gmail node if not already processed.
  • After sending email, use Data Store Push node to store the new email as processed.

This ensures that even if the workflow restarts or polling occurs again, it won’t resend to already processed emails.

Step 11: Testing and Deployment
  • Add new rows to your Google Sheet.
  • Wait for n8n polling to detect new rows.
  • Emails should be automatically sent via Gmail.
  • Check Gmail logs and your n8n executions for verification.
Optional Improvements
  • Error handling with try-catch or error workflows.
  • Log email sends into Google Sheets or Airtable.
  • Add OpenAI integration to generate dynamic email content.
  • Schedule digest summaries or notifications.
Conclusion

This entire automation requires zero coding and is fully handled inside n8n using its powerful visual workflow builder. With this setup, you can easily automate lead nurturing, onboarding emails, or any other email-based automation directly from Google Sheets.

The same approach can be extended into full-fledged AI-powered CRM bots, marketing automation flows, and complex integrations — all without writing any custom backend code.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top