Back to Catalog

Automatic Gmail categorization and labeling with AI

Matt Chong | n8n CreatorMatt Chong | n8n Creator
5178 views
2/3/2026
Official Page

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

Who is this for?

If your inbox is full of unread emails, this workflow is for you.
Instead of reading through them one by one, let AI do the sorting.
It reads your emails and flags only what needs action.

What does it solve?

This workflow reads your unread Gmail emails and uses AI to decide what’s important — and what’s not. It labels emails that need your attention, identifies receipts, and trashes everything else. No more manual reading. Just an inbox that uses AI to take care of itself.

How it works

  1. Every hour, the workflow runs automatically.
  2. It searches for unread emails in your Gmail inbox.
  3. For each email:
    • It extracts the content and sends it to OpenAI.
  4. The AI returns one of four labels: Action, Receipt, Informational or Spam.
  5. Based on the label:
    • Emails are marked with the appropriate label.
    • Or moved to trash it is spam.
  6. It marks the email as read once processed.

How to set up?

  1. Connect these services in your n8n credentials:
    • Gmail (OAuth2)
    • OpenAI (API key)
  2. Create the Gmail labels:
    • In your Gmail account, create these labels exactly as written:
      Action, Receipt, and Informational
    • The workflow will apply these labels based on AI classification.

How to customize this workflow to your needs

  • Change the AI prompt to detect more types of emails like Meeting or Newsletter.
  • Add more branches to the Switch node to apply custom logic.
  • Change the schedule to fit your workflow. By default, it runs every hour, but you can update this in the Schedule Trigger node.

Automatic Gmail Categorization and Labeling with AI

This n8n workflow automates the categorization and labeling of your Gmail emails using AI. It periodically checks your inbox, analyzes new emails with an AI agent, and then applies appropriate labels based on the AI's classification.

What it does

This workflow simplifies email management by:

  1. Polling Gmail: Regularly checks your Gmail inbox for new emails.
  2. AI Analysis: Sends the content of new emails to an AI agent (powered by OpenAI) for categorization.
  3. Structured Output Parsing: Processes the AI's response to extract structured categorization data.
  4. Conditional Labeling: Uses a Switch node to route the email based on the AI's categorization.
  5. Applying Labels: Applies the determined label (e.g., "Important", "Promotions", "Social") to the email in Gmail.
  6. Editing Fields: Prepares the email data for the next steps in the workflow.

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running n8n instance.
  • Gmail Account: A Gmail account with appropriate credentials configured in n8n.
  • OpenAI API Key: An OpenAI API key to power the AI agent and chat model. This needs to be configured as a credential in n8n for the "OpenAI Chat Model" and "AI Agent" nodes.

Setup/Usage

  1. Import the workflow: Download the provided JSON and import it into your n8n instance.
  2. Configure Credentials:
    • Gmail: Set up your Google OAuth2 credentials for Gmail.
    • OpenAI: Set up your OpenAI API Key credentials for the "OpenAI Chat Model" and "AI Agent" nodes.
  3. Activate the workflow: Once the credentials are set and the workflow is imported, activate it.
  4. Customize (Optional):
    • Schedule Trigger: Adjust the polling interval in the "Schedule Trigger" node if you want to check for emails more or less frequently.
    • AI Agent Prompt: Modify the prompt in the "AI Agent" node to refine how the AI categorizes your emails or to add new categories.
    • Switch Node: Add or modify conditions in the "Switch" node to handle additional categories or different labeling logic.
    • Gmail Labels: Ensure the labels specified in the "Gmail" nodes (e.g., "Important", "Promotions", "Social") exist in your Gmail account, or update the nodes to use your existing labels.

Related Templates

AI-powered code review with linting, red-marked corrections in Google Sheets & Slack

Advanced Code Review Automation (AI + Lint + Slack) Who’s it for For software engineers, QA teams, and tech leads who want to automate intelligent code reviews with both AI-driven suggestions and rule-based linting — all managed in Google Sheets with instant Slack summaries. How it works This workflow performs a two-layer review system: Lint Check: Runs a lightweight static analysis to find common issues (e.g., use of var, console.log, unbalanced braces). AI Review: Sends valid code to Gemini AI, which provides human-like review feedback with severity classification (Critical, Major, Minor) and visual highlights (red/orange tags). Formatter: Combines lint and AI results, calculating an overall score (0–10). Aggregator: Summarizes results for quick comparison. Google Sheets Writer: Appends results to your review log. Slack Notification: Posts a concise summary (e.g., number of issues and average score) to your team’s channel. How to set up Connect Google Sheets and Slack credentials in n8n. Replace placeholders (<YOURSPREADSHEETID>, <YOURSHEETGIDORNAME>, <YOURSLACKCHANNEL_ID>). Adjust the AI review prompt or lint rules as needed. Activate the workflow — reviews will start automatically whenever new code is added to the sheet. Requirements Google Sheets and Slack integrations enabled A configured AI node (Gemini, OpenAI, or compatible) Proper permissions to write to your target Google Sheet How to customize Add more linting rules (naming conventions, spacing, forbidden APIs) Extend the AI prompt for project-specific guidelines Customize the Slack message formatting Export analytics to a dashboard (e.g., Notion or Data Studio) Why it’s valuable This workflow brings realistic, team-oriented AI-assisted code review to n8n — combining the speed of automated linting with the nuance of human-style feedback. It saves time, improves code quality, and keeps your team’s review history transparent and centralized.

higashiyama By higashiyama
90

Daily cash flow reports with Google Sheets, Slack & Email for finance teams

Simplify financial oversight with this automated n8n workflow. Triggered daily, it fetches cash flow and expense data from a Google Sheet, analyzes inflows and outflows, validates records, and generates a comprehensive daily report. The workflow sends multi-channel notifications via email and Slack, ensuring finance professionals stay updated with real-time financial insights. 💸📧 Key Features Daily automation keeps cash flow tracking current. Analyzes inflows and outflows for actionable insights. Multi-channel alerts enhance team visibility. Logs maintain a detailed record in Google Sheets. Workflow Process The Every Day node triggers a daily check at a set time. Get Cash Flow Data retrieves financial data from a Google Sheet. Analyze Inflows & Outflows processes the data to identify trends and totals. Validate Records ensures all entries are complete and accurate. If records are valid, it branches to: Sends Email Daily Report to finance team members. Send Slack Alert to notify the team instantly. Logs to Sheet appends the summary data to a Google Sheet for tracking. Setup Instructions Import the workflow into n8n and configure Google Sheets OAuth2 for data access. Set the daily trigger time (e.g., 9:00 AM IST) in the "Every Day" node. Test the workflow by adding sample cash flow data and verifying reports. Adjust analysis parameters as needed for specific financial metrics. Prerequisites Google Sheets OAuth2 credentials Gmail API Key for email reports Slack Bot Token (with chat:write permissions) Structured financial data in a Google Sheet Google Sheet Structure: Create a sheet with columns: Date Cash Inflow Cash Outflow Category Notes Updated At Modification Options Customize the "Analyze Inflows & Outflows" node to include custom financial ratios. Adjust the "Validate Records" filter to flag anomalies or missing data. Modify email and Slack templates with branded formatting. Integrate with accounting tools (e.g., Xero) for live data feeds. Set different trigger times to align with your financial review schedule. Discover more workflows – Get in touch with us

Oneclick AI SquadBy Oneclick AI Squad
619

AI-powered document search with Oracle and ONNX embeddings for recruiting

How it works Create a user for doing Hybrid Search. Clear Existing Data, if present. Add Documents into the table. Create a hybrid index. Run Semantic search on the Documents table for "prioritize teamwork and leadership experience". Run Hybrid search for the text input in the Chat interface on the Documents table. Setup Steps Download the ONNX model allMiniLML12v2augmented.zip Extract the ZIP file on the database server into a directory, for example /opt/oracle/onnx. After extraction, the folder contents should look like: bash bash-4.4$ pwd /opt/oracle/onnx bash-4.4$ ls allMiniLML12_v2.onnx Connect as SYSDBA and create the DBA user sql -- Create DBA user CREATE USER app_admin IDENTIFIED BY "StrongPassword123" DEFAULT TABLESPACE users TEMPORARY TABLESPACE temp QUOTA UNLIMITED ON users; -- Grant privileges GRANT DBA TO app_admin; GRANT CREATE TABLESPACE, ALTER TABLESPACE, DROP TABLESPACE TO app_admin; Create n8n Oracle DB credentials hybridsearchuser → for hybrid search operations dbadocuser → for DBA setup (user and tablespace creation) Run the workflow Click the manual Trigger It displays Pure semantic search results. Enter search text in Chat interface It displays results for vector and keyword search. Note The workflow currently creates the hybrid search user, docuser with the password visible in plain text inside the n8n Execute SQL node. For better security, consider performing the user creation manually outside n8n. Oracle 23ai or 26ai Database has to be used. Reference Hybrid Search End-End Example

sudarshanBy sudarshan
211