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! ![]()

