Smart Gmail cleaner with AI validator & Telegram alerts
Automatically clean up your Gmail inbox by deleting unwanted emails, validated by Gemini AI.
Ideal for anyone tired of manual inbox cleanup, this workflow helps you save time while staying in control, with full transparency via Telegram alerts.
How it works
- Scans Gmail inbox in adjustable 2-week batches
- Uses Gemini AI to decide if an email should be deleted or skipped
- Applies a label to skipped emails to avoid rechecking in future runs
- Deletes unwanted emails and sends a Telegram message with the AI's reasoning
- Also notifies on skipped emails, with explanation included
Set up steps
- Connect your Gmail, Gemini AI, and Telegram accounts
- Adjust the AI baseline to control sensitivity (e.g. how strict the filtering should be)
- Set your batch range (default: last 2 weeks, adjustable)
- Define your Telegram chat/channel for notifications
Note: Thanks to n8n's modular design, you can easily switch Gemini for another AI model (like OpenAI, Claude, etc.) or replace Telegram with Discord, Slack, or even email, no code changes needed, just swap the nodes.
Smart Gmail Cleaner with AI Validator & Telegram Alerts
This n8n workflow automates the process of cleaning up your Gmail inbox by identifying and processing specific emails, validating their content using AI, and sending alerts via Telegram. It's designed to help you manage your inbox more efficiently by automatically handling emails that meet certain criteria.
What it does
This workflow performs the following key steps:
- Manual Trigger: The workflow is initiated manually, allowing you to run it on demand.
- Gmail Email Retrieval: It connects to your Gmail account to retrieve emails. (The specific criteria for email retrieval are not defined in the provided JSON, but would typically be configured in the Gmail node).
- AI Content Validation: The retrieved email content is passed to an AI Agent (likely a Large Language Model like Google Gemini) for analysis and validation. This step likely checks if the email content meets certain criteria for deletion or further action.
- Structured Output Parsing: The AI Agent's response is then parsed to extract structured information, ensuring that the output is consistent and usable for subsequent steps.
- Conditional Logic (If Statement): Based on the AI validation, the workflow uses an "If" node to route the email.
- TRUE Branch: If the AI validation returns
true(indicating the email should be processed), the workflow proceeds to edit fields and send a Telegram alert. - FALSE Branch: If the AI validation returns
false(indicating the email should not be processed), the workflow does nothing further for that email.
- TRUE Branch: If the AI validation returns
- Edit Fields (Set): For emails that pass the AI validation, this node likely modifies or adds specific data points related to the email, preparing it for the next action.
- Telegram Alert: A message is sent to a specified Telegram chat, alerting you about the processed email. This could include details about the email and the action taken.
- Aggregate (Optional): The workflow includes an "Aggregate" node, which could be used to combine or summarize data from multiple processed emails before a final action, though its specific use case here is not fully detailed by the JSON.
- No Operation: The "No Operation" node on the
falsebranch simply acts as a placeholder, indicating that no action is taken for emails that do not meet the AI validation criteria.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running instance of n8n.
- Gmail Account: Credentials for a Gmail account to access your emails.
- Google Gemini (or similar LLM) API Key/Access: Credentials for an AI service (like Google Gemini) to power the AI Agent and Chat Model nodes.
- Telegram Account & Bot Token: A Telegram bot and its token, along with the chat ID where you want to receive alerts.
Setup/Usage
- Import the Workflow: Import the provided JSON into your n8n instance.
- Configure Credentials:
- Set up your Gmail credentials (OAuth 2.0 is recommended).
- Configure your Google Gemini Chat Model credentials (API key or service account).
- Set up your Telegram credentials (Bot Token).
- Customize Nodes:
- Gmail Node: Adjust the "Gmail" node to specify which emails to retrieve (e.g., search queries, labels, unread status).
- AI Agent Node: Configure the "AI Agent" node with the specific instructions or prompts for validating email content. This is crucial for defining what constitutes a "cleanable" email.
- Structured Output Parser: Ensure the parser is configured to correctly extract the validation result from the AI Agent's output.
- If Node: Verify the condition in the "If" node to correctly evaluate the AI validation result.
- Edit Fields (Set) Node: Customize the fields you want to set or modify based on the email content.
- Telegram Node: Specify the
chat IDand customize the message content for the alerts.
- Execute Workflow: Run the workflow manually using the "When clicking ‘Execute workflow’" trigger to test its functionality. Once satisfied, you can set it up to run on a schedule or via a webhook for continuous automation.
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.
Generate Weather-Based Date Itineraries with Google Places, OpenRouter AI, and Slack
🧩 What this template does This workflow builds a 120-minute local date course around your starting point by querying Google Places for nearby spots, selecting the top candidates, fetching real-time weather data, letting an AI generate a matching emoji, and drafting a friendly itinerary summary with an LLM in both English and Japanese. It then posts the full bilingual plan with a walking route link and weather emoji to Slack. 👥 Who it’s for Makers and teams who want a plug-and-play bilingual local itinerary generator with weather awareness — no custom code required. ⚙️ How it works Trigger – Manual (or schedule/webhook). Discovery – Google Places nearby search within a configurable radius. Selection – Rank by rating and pick the top 3. Weather – Fetch current weather (via OpenWeatherMap). Emoji – Use an AI model to match the weather with an emoji 🌤️. Planning – An LLM writes the itinerary in Markdown (JP + EN). Route – Compose a Google Maps walking route URL. Share – Post the bilingual itinerary, route link, and weather emoji to Slack. 🧰 Requirements n8n (Cloud or self-hosted) Google Maps Platform (Places API) OpenWeatherMap API key Slack Bot (chat:write) LLM provider (e.g., OpenRouter or DeepL for translation) 🚀 Setup (quick) Open Set → Fields: Config and fill in coords/radius/time limit. Connect Credentials for Google, OpenWeatherMap, Slack, and your LLM. Test the workflow and confirm the bilingual plan + weather emoji appear in Slack. 🛠 Customize Adjust ranking filters (type, min rating). Modify translation settings (target language or tone). Change output layout (side-by-side vs separated). Tune emoji logic or travel mode. Add error handling, retries, or logging for production use.
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