Automated Gmail Message Logger to Google Sheets - n8n Workflow

Use this efficient n8n workflow to automatically log new Gmail messages into Google Sheets. Perfect n8n template for creating lightweight CRMs or tracking communications using an n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users who need an audit trail or historical log of all incoming emails.
Teams building lightweight, self-managed customer relationship management (CRM) systems.
Developers looking for a reliable n8n template to monitor mailbox activity.
Anyone seeking to synchronize their email activity with a structured database like Google Sheets.

Overview

Keeping track of all incoming emails can be challenging, especially when you need a structured, queryable log outside of your mailbox. This robust n8n workflow solves that by providing an automated mechanism to fetch and record new Gmail messages into a Google Sheet.

Unlike simpler setups, this n8n template intelligently determines the last run time by reading the existing data in the Google Sheet first. This ensures that the Gmail n8n node only fetches emails received since the last successful log, preventing duplication and ensuring high efficiency. The resulting output is a tidy spreadsheet containing the message ID, snippet, and the exact timestamp when the n8n workflow processed the message, making this an essential n8n node sequence for data management.

How it Works

This n8n workflow initiates execution via a manual n8n trigger (designed to be run manually or scheduled).


  1. Determine Last Log Date: The process begins by fetching all records from the target Google Sheet using an n8n node. A Summarize n8n node then analyzes the data to extract the maximum (most recent) datetime recorded. This date is crucial for filtering new emails.

  2. Generate Current Timestamp: Simultaneously, an n8n Code node generates the current ISO timestamp, which will be used to log the new emails being added.

  3. Fetch New Emails: A Merge n8n node combines the max date (from the sheet) and the current timestamp. The Gmail n8n node uses the extracted maximum date to set the receivedAfter filter. This ensures that the workflow efficiently retrieves only messages newer than the last recorded entry.

  4. Log Data: Finally, a Google Sheets n8n node takes the newly fetched Gmail messages and appends them to the specified spreadsheet. It logs the Gmail message ID, the email snippet, and the current processing date (generated in step 2), ensuring consistent and non-duplicative logging using this powerful n8n workflow.

Installation Guide

To deploy this useful n8n workflow, follow these steps:


  1. Import the Workflow: Copy the provided JSON and import it into your n8n instance.

  2. Google Sheet Setup: Copy the provided Google Sheet template (containing columns for id, snippet, and datetime) into your own Google Drive.

  3. Gmail Credential Setup: Create a new Gmail OAuth2 credential in n8n. Log in with your Gmail account and approve access. Attach this credential to the Get new messages n8n node.

  4. Google Sheets Credential Setup: Create a new Google Sheets OAuth2 credential in n8n. Log in and save the credential.

  5. Configure Google Sheets Nodes: In both the Get Current Emails and Add Emails to Sheets n8n nodes, select your newly created Google Sheets credential. Then, specify the Spreadsheet ID and the Worksheet Name (typically 'Sheet1') corresponding to your copy of the template.

  6. Activation: Save the n8n workflow and click 'Activate' to enable scheduled or manual runs. Use the n8n trigger manually for testing.

Node Details

This n8n workflow utilizes several key n8n nodes:

When clicking ‘Execute workflow’ (Manual Trigger): The primary n8n trigger used for running the automation, typically set up for scheduled execution.
Get Current Emails (Google Sheets n8n node): Operation set to 'Get All'. Reads all data from the spreadsheet. This is the first step in the data lifecycle of this n8n template, used to establish the history.
Get Max Date (Summarize n8n node): Function set to find the 'max' value for the datetime field retrieved from the sheet. This extracted value (maxdatetime) is critical for the efficiency of the overall n8n workflow.
Get Todays Date (Code n8n node): Executes JavaScript to generate the current ISO 8601 timestamp. This ensures a uniform logging date for all new emails processed during the current n8n run.
Get new messages (Gmail n8n node): Operation set to getAll. Crucially, it uses an expression filter: receivedAfter: {{ $json.maxdatetime }}. This is how the n8n node limits the results to truly new emails.
Add Emails to Sheets (Google Sheets n8n node): Operation set to appendOrUpdate. It maps the incoming data from the Gmail n8n node to the sheet columns, appending new rows with the message ID, snippet, and the current logging timestamp.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

Featured*