Skip to main content

Automatically rename Gmail attachments with GPT-4o and save to Google Drive

Workflow preview

Workflow preview
100%
Automatically rename Gmail attachments with GPT-4o and save to Google Drive preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Automatically Rename Gmail Attachments with AI and Save to Google Drive Who is this for? This workflow is perfect for anyone who regularly receives important email attachments like reports, invoice...

Best for

  • AI Summarization automation workflows
  • Multimodal AI automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.googledrive, n8n-nodes-base.gmail, n8n-nodes-base.merge, n8n-nodes-base.set, n8n-nodes-base.extractfromfile

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Matt Chong | n8n Creator.

Original n8n.io source

1.1 Workflow description

Title
Automatically rename Gmail attachments with GPT-4o and save to Google Drive
Workflow name
Automatically rename Gmail attachments with GPT-4o and save to Google Drive

Automatically Rename Gmail Attachments with AI and Save to Google Drive

Who is this for?

This workflow is perfect for anyone who regularly receives important email attachments like reports, invoices, or PDFs and wants them:

  • Renamed using clean AI generated filenames
  • Automatically saved to a specific Google Drive folder
  • Neatly organized without manual work

It is ideal for freelancers, business owners, accountants, and productivity enthusiasts.

What does it solve?

Manually naming and organizing email attachments takes time and often leads to messy files.

This workflow solves that by:

  • Automatically downloading unread Gmail attachments
  • Using AI to understand the content and generate clean, consistent filenames
  • Saving the renamed files to your chosen Google Drive folder
  • Marking emails as read after processing

No more confusing filenames like "Attachment 1.pdf".

How it works

  1. The workflow runs on a scheduled interval (every hour by default)
  2. It checks Gmail for any unread emails with attachments.
  3. For each email:
    • Downloads attachments
    • Extracts and reads PDF content
    • Uses AI to generate a new filename in the format: YYYYMMDD-keyword-summary.pdf
  4. Saves the file to Google Drive with the new name
  5. Marks the email as read to avoid duplicates

How to set up?

  1. Connect these accounts in your n8n credentials:

    • Gmail (OAuth2)
    • Google Drive (OAuth2)
    • OpenAI (API key)
  2. Update the folder URL in the Google Drive node to your target folder

  3. Optional: adjust the trigger interval if you want it to run more or less often

How to customize this workflow to your needs

  • Change the AI prompt to create different naming rules, such as including sender or topic
  • Dynamically set Drive folders based on email sender or subject

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 2 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 3 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 4 - Upload file

Type / Role
n8n-nodes-base.googleDrive - googleDrive
Config choices
Version 3

Block 5 - Mark message as read

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 6 - Merge Data for Upload

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 7 - Get Unread Messages with Attachments

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 8 - Set Required Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - Download Attachments

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 10 - Extract from Attachments

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

3. Summary Table

Workflow Automatically rename Gmail attachments with GPT-4o and save to Google Drive
Complexity intermediate
Nodes 10
Categories AI Summarization, Multimodal AI
Author Matt Chong | n8n Creator
Published 19 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7585/7585.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automatically rename Gmail attachments with GPT-4o and save to Google Drive do?

Automatically Rename Gmail Attachments with AI and Save to Google Drive Who is this for? This workflow is perfect for anyone who regularly receives important email attachments like reports, invoice...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your AI Summarization, Multimodal AI use case.