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
- A scheduled trigger runs the workflow (you set how often).
- It fetches all read emails older than 45 days from Gmail.
- Each email is passed to an AI model(GPT-4) that classifies it as:
- Actionable
- Archive
- If the AI recommends archiving, the workflow archives the email from your inbox.
- All other emails are left untouched so you can review them as needed.
How to set up?
- Connect your Gmail (OAuth2) and OpenAI API credentials.
- Open the "Schedule Trigger" node and choose how often the workflow should run (e.g., daily, weekly).
- Optionally adjust the Gmail filter in the “List Old Emails” node to change which emails are targeted.
- 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).
Declutter Gmail: Archive Inactive Emails with AI Classification
This n8n workflow automates the process of identifying and archiving inactive emails in your Gmail inbox, leveraging AI to classify email activity. It helps you maintain a cleaner, more organized inbox by automatically moving emails that are no longer relevant to an archive.
What it does
This workflow performs the following steps:
- Triggers on a Schedule: The workflow starts at predefined intervals (e.g., daily, weekly) to scan your Gmail inbox.
- Fetches Gmail Emails: It retrieves a batch of emails from your Gmail account.
- Loops Through Emails: Each retrieved email is processed individually.
- Classifies Email Activity with AI: For each email, an AI Agent (powered by an OpenAI Chat Model) analyzes its content to determine if it's "inactive" or "active".
- Parses AI Output: The AI's classification is parsed to extract the structured decision (e.g., "archive" or "keep").
- Conditional Archiving:
- If the AI classifies an email as "inactive" (archive), the email is moved to the "Archive" folder in Gmail.
- If the AI classifies an email as "active" (keep), no action is taken, and the email remains in the inbox.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running n8n instance.
- Gmail Account: A configured Gmail credential in n8n with access to your emails.
- OpenAI API Key: An OpenAI credential configured in n8n to power the AI Agent and Chat Model. This is used for email classification.
Setup/Usage
- Import the Workflow: Download the JSON provided and import it into your n8n instance.
- Configure Credentials:
- Gmail: Set up your Gmail OAuth2 or API Key credential.
- OpenAI: Set up your OpenAI API Key credential.
- Activate the Workflow: Once configured, activate the workflow. It will run automatically based on the schedule defined in the "Schedule Trigger" node. You can adjust the schedule to your preference (e.g., once a day, once a week).
- Review AI Agent Prompt: You may want to review and adjust the prompt within the "AI Agent" node to fine-tune how it classifies emails based on your specific definition of "inactive" or "active."
Related Templates
Automated YouTube video uploads with 12h interval scheduling in JST
This workflow automates a batch upload of multiple videos to YouTube, spacing each upload 12 hours apart in Japan Standard Time (UTC+9) and automatically adding them to a playlist. ⚙️ Workflow Logic Manual Trigger — Starts the workflow manually. List Video Files — Uses a shell command to find all .mp4 files under the specified directory (/opt/downloads/单词卡/A1-A2). Sort and Generate Items — Sorts videos by day number (dayXX) extracted from filenames and assigns a sequential order value. Calculate Publish Schedule (+12h Interval) — Computes the next rounded JST hour plus a configurable buffer (default 30 min). Staggers each video’s scheduled time by order × 12 hours. Converts JST back to UTC for YouTube’s publishAt field. Split in Batches (1 per video) — Iterates over each video item. Read Video File — Loads the corresponding video from disk. Upload to YouTube (Scheduled) — Uploads the video privately with the computed publishAtUtc. Add to Playlist — Adds the newly uploaded video to the target playlist. 🕒 Highlights Timezone-safe: Pure UTC ↔ JST conversion avoids double-offset errors. Sequential scheduling: Ensures each upload is 12 hours apart to prevent clustering. Customizable: Change SPANHOURS, BUFFERMIN, or directory paths easily. Retry-ready: Each upload and playlist step has retry logic to handle transient errors. 💡 Typical Use Cases Multi-part educational video series (e.g., A1–A2 English learning). Regular content release cadence without manual scheduling. Automated YouTube publishing pipelines for pre-produced content. --- Author: Zane Category: Automation / YouTube / Scheduler Timezone: JST (UTC+09:00)
Detect holiday conflicts & suggest meeting reschedules with Google Calendar and Slack
Who’s it for Remote and distributed teams that schedule across time zones and want to avoid meetings landing on public holidays—PMs, CS/AM teams, and ops leads who own cross-regional calendars. What it does / How it works The workflow checks next week’s Google Calendar events, compares event dates against public holidays for selected country codes, and produces a single Slack digest with any conflicts plus suggested alternative dates. Core steps: Workflow Configuration (Set) → Fetch Public Holidays (via a public holiday API such as Calendarific/Nager.Date) → Get Next Week Calendar Events (Google Calendar) → Detect Holiday Conflicts (compare dates) → Generate Reschedule Suggestions (find nearest business day that isn’t a holiday/weekend) → Format Slack Digest → Post Slack Digest. How to set up Open Workflow Configuration (Set) and edit: countryCodes, calendarId, slackChannel, nextWeekStart, nextWeekEnd. Connect your own Google Calendar and Slack credentials in n8n (no hardcoded keys). (Optional) Adjust the Trigger to run daily or only on Mondays. Requirements n8n (Cloud or self-hosted) Google Calendar read access to the target calendar Slack app with permission to post to the chosen channel A public-holiday API (no secrets needed for Nager.Date; Calendarific requires an API key) How to customize the workflow Time window: Change nextWeekStart/End to scan a different period. Holiday sources: Add or swap APIs; merge multiple regions. Suggestion logic: Tweak the look-ahead window or rules (e.g., skip Fridays). Output: Post per-calendar messages, DM owners, or create tentative reschedule events automatically.
Generate event speaker recommendations with Claude AI and Google Sheets
Simplify event planning with this automated n8n workflow. Triggered by incoming requests, it fetches speaker and audience data from Google Sheets, analyzes profiles and preferences, and generates optimized session recommendations. The workflow delivers formatted voice responses and updates tracking data, ensuring organizers receive real-time, tailored suggestions. 🎙️📊 Key Features Real-time analysis of speaker and audience data for personalized recommendations. Generates optimized session lineups based on profiles and preferences. Delivers responses via voice agent for a seamless experience. Logs maintain a detailed recommendation history in Google Sheets. Workflow Process The Webhook Trigger node initiates the workflow upon receiving voice agent or external system requests. Parse Voice Request processes incoming voice data into actionable parameters. Fetch Database retrieves speaker ratings, past sessions, and audience ratings from Google Sheets. Calculate & Analyze combines voice request data with speaker profiles and audience insights for comprehensive matching. AI Optimization Engine analyzes speaker-audience fit and recommends optimal session lineups. Format Recommendations structures the recommendations for voice agent response. Voice Agent Response returns formatted recommendations to the user with natural language summary and structured data. Update Tracking Sheet saves recommendation history and analytics to Google Sheets. If errors occur, the Check for Errors node branches to: Format Error Response prepares an error message. Send Error Response delivers the error notification. Setup Instructions Import the workflow into n8n and configure Google Sheets OAuth2 for data access. Set up the Webhook Trigger with your voice agent or external system's API credentials. Configure the AI Optimization Engine node with a suitable language model (e.g., Anthropic Chat Model). Test the workflow by sending sample voice requests and verifying recommendations. Adjust analysis parameters as needed for specific event requirements. Prerequisites Google Sheets OAuth2 credentials Voice agent API or integration service AI/LLM service for optimization (e.g., Anthropic) Structured speaker and audience data in a Google Sheet Google Sheet Structure: Create a sheet with columns: Speaker Name Rating Past Sessions Audience Rating Preferences Updated At Modification Options Customize the Calculate & Analyze node to include additional matching criteria (e.g., topic expertise). Adjust the AI Optimization Engine to prioritize specific session formats or durations. Modify voice response templates in the Voice Agent Response node with branded phrasing. Integrate with event management tools (e.g., Eventbrite) for live data feeds. Set custom error handling rules in the Check for Errors node. Discover more workflows – Get in touch with us