Hey everyone! ![]()
Sharing my first n8n build here!
I had around 7,000 emails sitting in my Gmail inbox and I was too lazy to clean them manually β so I built an automation to do it for me.
What it does
Every morning at 6 AM, it:
- Fetches unprocessed inbox emails
- Checks my Telegram sender/domain rules first
- If no rule exists, asks Gemini AI to classify the email
- Applies a Gmail label (priority, receipts, unimportant, email-subs, or please-review)
- Archives it out of my inbox
- Sends me a Telegram summary when itβs done
If AI is unsure about an email, it goes to please-review β it never guesses silently.
I can also manage rules straight from Telegram:
/whitelist boss@company.com β priority
/blacklistdomain spammy-site.com β unimportant
/receipt orders@store.com β receipts
Architecture
| Workflow | Nodes | Purpose |
|---|---|---|
| A β Daily Orchestrator | 25 | Fetches inbox, applies rules, calls child, summarizes |
| B β Email Processor | 19 | Classifies and labels one email at a time |
| C β Telegram Rules Manager | 11 | Manage rules via Telegram bot |
55 nodes total. Budget: β±0.
Stack
n8n (self-hosted) + Gemini AI + Gmail API + Telegram Bot + Neon Postgres + ngrok
Everything runs on free tier.
Some n8n gotchas I discovered (might help others!)
During deployment I ran into a few issues that took a while to figure out:
-
Import wiring corruption β IF, Switch, and SplitInBatches nodes can have internally corrupted output mappings after JSON import. The wires look correct visually but route data to the wrong outputs during execution. Fix: delete the node and recreate it from scratch.
-
SplitInBatches infinite loop β If your Wait node accidentally loops back to a node before SplitInBatches instead of directly back to it, the batch restarts from item 1 forever. Caught this one after 60+ loops.

-
Gmail metadata capitalization β Gmail returns
From,Subject,Date(capitalized) but code might expect lowercasefrom,subject,date. Need to check both or all your emails show empty sender and β(no subject)β.
All documented in the deployment guide with step-by-step fixes.
Links
Full deployment guide, troubleshooting, and schema included. MIT License.
About me
Iβm not a developer β Iβm a non-technical automation builder from Manila. This is my first GitHub project and my first n8n community post!
Built it because I was lazy. Stayed because it actually works. ![]()
Would love feedback, ideas, or questions! ![]()

