Skip to main content

Declutter Gmail: archive inactive emails with GPT-4 classification

Workflow preview

Workflow preview
100%
Declutter Gmail: archive inactive emails with GPT-4 classification preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Who is this for? This workflow is for professionals, entrepreneurs, or anyone overwhelmed by a cluttered Gmail inbox. If you want to automatically archive low priority emails using AI, this is the ...

Best for

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

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.gmail, n8n-nodes-base.set, n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.noop

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
Declutter Gmail: archive inactive emails with GPT-4 classification
Workflow name
Declutter Gmail: archive inactive emails with GPT-4 classification

Who is this for?

This workflow is for professionals, entrepreneurs, or anyone overwhelmed by a cluttered Gmail inbox. If you want to automatically archive low-priority emails using AI, this is the perfect hands-free solution.

What does it solve?

Your inbox fills up with old, read emails that no longer need your attention but manually archiving them takes time. This workflow uses AI to scan and intelligently decide whether each email should be archived, needs a reply, or is spam. It helps you:

  • Declutter your Gmail inbox automatically
  • Identify important vs. unimportant emails
  • Save time with smart email triage

How it works

  1. A scheduled trigger runs the workflow (you set how often).
  2. It fetches all read emails older than 45 days from Gmail.
  3. Each email is passed to an AI model(GPT-4) that classifies it as:
    • Actionable
    • Archive
  4. If the AI recommends archiving, the workflow archives the email from your inbox.
  5. All other emails are left untouched so you can review them as needed.

How to set up?

  1. Connect your Gmail (OAuth2) and OpenAI API credentials.
  2. Open the "Schedule Trigger" node and choose how often the workflow should run (e.g., daily, weekly).
  3. Optionally adjust the Gmail filter in the “List Old Emails” node to change which emails are targeted.
  4. Start the workflow and let AI clean up your inbox automatically.

How to customize this workflow to your needs

  • Change the Gmail filter: Edit the query in the Gmail node to include other conditions (e.g., older_than:30d, specific labels, unread only).
  • Update the AI prompt: Modify the prompt in the Function node to detect more nuanced categories like “Meeting Invite” or “Newsletter.”
  • Adjust schedule frequency: Change how often the cleanup runs (e.g., hourly, daily).

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 - List old inbox emails

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

Block 3 - Prep Email for AI

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

Block 4 - Loop Over Emails

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

Block 5 - AI Agent

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

Block 6 - OpenAI Chat Model

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

Block 7 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 8 - Completed

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

Block 9 - If - Should archived?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 10 - Sticky Note

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

Block 11 - Sticky Note1

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

Block 12 - Sticky Note2

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

Block 13 - Archive Email

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

3. Summary Table

Workflow Declutter Gmail: archive inactive emails with GPT-4 classification
Complexity intermediate
Nodes 13
Categories AI Summarization, Multimodal AI
Author Matt Chong | n8n Creator
Published 24 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7780/7780.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 Declutter Gmail: archive inactive emails with GPT-4 classification do?

Who is this for? This workflow is for professionals, entrepreneurs, or anyone overwhelmed by a cluttered Gmail inbox. If you want to automatically archive low priority emails using AI, this is the ...

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.