Email Management: Auto-Delete Marketing Emails & Generate AI Replies with Gemini

Description This workflow intelligently scans your inbox, detects whether an email is marketing or genuine, and takes the right action automatically.

Marketing Emails : Deleted instantly and logged in Google Sheets for tracking.

Non-Marketing Emails : Receive a customized, polite reply crafted using AI.

Tracking : Every action (delete/reply) is recorded for auditing and reference.

Accounts & Tools

n8n instance (self-hosted or cloud). Google account with: Gmail API access (for reading, deleting, and replying). Google Sheets API access (for logging deleted/replied emails). IMP/SMTP credentials (if using IMAP trigger instead of Gmail API). Google Gemini (PaLM) API key to classify emails and generate replies.

Setup instructions Create a n8N account on cloud or install it locally. follow the quick start guide this Define your trigger point for your workflow as how or when this needs to run. Currently IMAP has been used to detect if any email is received and if so, trigger the workflow Now, we need to setup the google account which allows our workflow to read emails. Follow this guideline to setup gmail account Next step is to add an AI tool which is google gemini here. To set up and use, see this guideline Since AI response is in text, we need a parser tool to read a specific value from text Setup a categorization tool like this Next is to send or delete email and for this, an existing gmail setup is going to work In the last, we need to set a connection for sheet to keep the logs. Adding any sheet to workflow can be seen as google sheet integration

How it work Once any emails is received, IMAP detects and starts the workflow. Now, email is passed to AI model to see if this email is a marketing email or not. Also, is its not a marketing email, it generates a tailored response. Currently, sender, subject and body of email is being scanned and marked as marketing based on model's feedback. Since AI response is in text format, using a formattor to parse it Next step is to read its category as if it is a marketing email Based on email type, there are 2 steps: delete email if it is a marketing email Read the response from previos node and send that as reply Last step is track this activity as which emails is deleted or replied. In terms of structure of sheet, it has 2 tabs deleted emails & replied emails and both have 2 columns Email ID subject

Future Use it to categories emails for wider range like job applications, bills, customer supprt and tailor replies for each categories seperately Logging can done in wider sources like databases etc In case if we are logging on sheet, a further enhancements like follow up emails etc can be done

0
Downloads
0
Views
8.04
Quality Score
beginner
Complexity
Author:Raghvendra dixit(View Original β†’)
Created:9/10/2025
Updated:10/17/2025

πŸ”’ Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments