← Back to list

Update. AI Fraud & Spam Detector with n8n

I Built an AI Fraud & Spam Detector with n8n — Bank Loans, Credit Cards, Mutual Funds, and Phishing, All in One Workflow

Jatinkumar Parmar in GoPenAI · 2026-08-01 04:06 · 0 claps · 6.0 min read paywalled
#indian-startups #data-science #tech-for-good #investment-scams #fraud-detection
Open on Medium ↗
Wiki topics: ML · Machine Learning INV · Investing & Markets STP · Startups & Venture 🔒 · Cybersecurity 🔬 · Science · General

Update. AI Fraud & Spam Detector with n8n

I Built an AI Fraud & Spam Detector with n8n — Bank Loans, Credit Cards, Mutual Funds, and Phishing, All in One Workflow

How I combined Gmail, Gemini 2.5 Flash, and n8n to auto-catch loan scams, credit card fraud, fake mutual fund/SIP schemes, and phishing before they waste your time — in real time

If you run a business inbox in India, you already know the pattern: “pre-approved loan, no CIBIL check,” “your credit card will be blocked, share CVV to verify,” “guaranteed 30% returns — SEBI registered,” and fifty marketing blasts a day burying the one email that actually matters.

I got tired of manually triaging this, so I built a single automated classifier using n8n + Gemini that reads every incoming email, figures out which kind of scam it is, scores it for fraud risk, and routes it — quarantine, review, or let it through — without me touching it.

Here’s the full build, step by step.

The Real Problem: Fraud Doesn’t Wait, So Detection Can’t Either

This isn’t a hypothetical annoyance — it’s a live, growing crisis:

  • India’s financial fraud losses have been climbing into the thousands of crores annually, with loan-scam and phishing emails as a major entry point into the funnel — the email is rarely the endgame, it’s the first click that leads to OTP theft, fake KYC forms, or advance-fee payments.
  • Speed is the whole game. A scam email that sits in an inbox for even a few hours before someone notices it is a few hours where a less careful employee, family member, or customer could click through, “verify” an OTP, or wire an “advance fee.” Manual review — checking mail once a day, once an hour — is structurally too slow for how fast these campaigns move.
  • Static keyword filters get stale within weeks because scammers rotate phrasing constantly (“no CIBIL” becomes “zero CIBIL check,” “verify OTP” becomes “confirm code”). A rules list you maintain by hand is always one step behind.
  • Businesses and freelancers (the exact audience building automation like this) are high-value targets precisely because they don’t have a dedicated security team watching the inbox 24/7.

The solution has to be real-time, not batch. That’s the actual design constraint behind this workflow — not “scan emails,” but “catch it in the seconds between arrival and someone opening it.”

How this workflow solves it in real time

  • Gmail Trigger polls continuously (every minute in this build, and can be tightened further) — no end-of-day digest, no waiting for a human to open the inbox.
  • Classification happens inline, before the email is ever surfaced to a person — by the time you’d normally glance at your inbox, the fraud ones are already labeled and the high-risk ones have already pinged Slack.
  • The LLM classifier adapts to new phrasing automatically — because it’s reasoning about intent (“is this impersonating a bank and creating urgency around a financial action?”), not matching a fixed keyword list. New scam wording doesn’t need a code deploy to catch; the model already generalizes.
  • Alerting is immediate, not queued — the Slack alert on quarantine fires in the same execution as the classification, so the window between “scam lands” and “someone credible is notified” is seconds, not hours.

This is the difference between a spam filter and a fraud defense system: one cleans up your inbox, the other closes the time gap that scammers depend on.

Why I Built This

Five categories of junk kept flooding my inbox:

  1. Loan scams — fake “instant disbursal, no CIBIL” offers impersonating banks/NBFCs
  2. Credit card fraud — fake card-blocked urgency, CVV/OTP harvesting, fake reward-point redemption links
  3. Investment/mutual fund scams — guaranteed-return SIP pitches, fake SEBI/AMFI registration claims, Ponzi-style referral schemes
  4. Phishing — OTP/PAN/Aadhaar “verify your account” emails with spoofed sender domains
  5. Marketing spam — legitimate but unsolicited bulk sends

Keyword filters catch maybe half of this. An LLM that actually reads intent catches almost all of it — and tells you why it flagged something, which matters when you’re deciding whether to trust the call.

Step 1: Trigger on New Email

Start with a Gmail Trigger node polling the inbox every minute, filtered to INBOX only. This is the entry point — every new email kicks off the pipeline.

Step 2: Extract Signal, Not Just Text

A Code node pulls out the features that actually matter for classification, instead of dumping raw HTML into the LLM:

  • Sender address + domain (spoofed domains are a huge tell)
  • All links found in the body
  • Four regex flags: hasUrgencyWords (urgent, verify now, account suspended, OTP, PAN, Aadhaar), hasLoanWords (pre-approved, EMI, instant disbursal, no CIBIL), hasCreditCardWords (card blocked, CVV, reward points redeem), and hasInvestmentWords (mutual fund, SIP, guaranteed return, SEBI/AMFI claims)

Pre-computing these signals means the LLM isn’t guessing — it’s reasoning over structured evidence.

Step 3: Classify with Gemini 2.5 Flash

An HTTP Request node calls Gemini directly (header auth via X-goog-api-key, no bound credential object needed) with a tight system prompt:

Return ONLY valid JSON: category (phishing / loan_scam / credit_card_fraud / investment_scam / marketing_spam / legit), risk_score (0–100), reasons, recommended_action (quarantine / review / allow).

Risk thresholds: >70 quarantine, 40–70 review, <40 allow. This keeps the model from making silent judgment calls — every decision has a numeric score and a plain-English reason attached, and now it also tells you which kind of scam it caught.

Step 4: Route by Risk, Not by Guesswork

A Switch node reads the model’s recommended_action (mapped to a numeric index — quarantine=0, review=1, allow=2) and branches three ways:

  • 🔴 Quarantine → Gmail label “Fraud” + instant Slack alert
  • 🟡 Review → Gmail label “Review-Fraud” + logged to Sheets for a human to eyeball later
  • 🟢 Allow → logged to Sheets, email passes through untouched

Step 5: Log Everything

Every classified email — including the “allow” ones — gets a row in Google Sheets: timestamp, sender, domain, category, risk score, action, reasons. This becomes your audit trail and, over time, a labeled dataset if you ever want to fine-tune your own classifier.

Step 6: The One Rule I Won’t Break

No auto-delete. No auto-block. The workflow labels and alerts — it never deletes a message or blocks a sender on its own. A false positive quarantining a real bank email costs you more than a missed spam message ever will. The “Review” lane exists specifically to keep a human in the loop on anything that isn’t a clear-cut case.

What’s Next

I’m extending this same classifier to WhatsApp/SMS, since a huge share of loan and EMI fraud in India arrives by text, not email — and wiring flagged sender domains back into outreach tooling so known-bad domains get auto-excluded from future lead lists.

If you want to build this yourself, the pattern is simple: extract signal → let an LLM classify with a strict schema → route by score → always keep a human review lane. That structure works for spam, but it also works for support ticket triage, lead qualification, or content moderation — anywhere you need a machine to make a first pass and a human to make the final call.

By Jatin Parmar | Shiva AI LLP | linkedin.com/in/jhparmar | github.com/parmarjh

Tags: #n8n #AIAutomation #FraudDetection #CreditCardFraud #InvestmentScam #CyberSecurity #NoCode #GenAI #EmailSecurity #Fintech #Gemini #WorkflowAutomation #IndianStartups #TechForGood #DataScience

Deciphered ambiguous request, expanded fraud categories, flagged call recording legality

Deciphered ambiguous request, expanded fraud categories, flagged call recording legality

Two different things bundled here — let me split them.

1) Bank loan + credit card + mutual fund fraud, all in one classifier — straightforward, I’ll extend the same workflow’s category list rather than build separate flows.

2) Call recording + auto-accept for “important” calls — this is a different system (phone/telephony, not email) and touches consent laws, so I need one detail from you before I build it for real.

Let me do #1 now and ask about #2.

Augmented keyword detection system with updated parameters

Augmented keyword detection system with updated parameters

Updated — now one workflow, 5 categories: loan_scam | credit_card_fraud | investment_scam (mutual fund/SIP/stock-tip Ponzi patterns) | phishing | marketing_spam. Same Gemini node, same Switch/routing, no new nodes needed — just extended the prompt + added hasCreditCardWords / hasInvestmentWords signal flags in the Extract Features code node.

Now, the call part — before I build anything:

Recording phone calls and auto-accepting based on “importance” is a different system (telephony, not email/n8n Code nodes), and it has a real legal line: in India, recording a call without informing the other party can violate telecom/IT rules — most legitimate call-recording setups play an IVR notice (“this call may be recorded”) first. I’m not going to build silent/secret call recording, but a consent-announced call screening + recording system is completely doable.

To build it for real I need one thing from you:

  • What’s the calling number connected to? — a mobile SIM (needs Truecaller-style call screening app), a business VoIP number (Exotel/Twilio — these plug into n8n via webhook and support recording + IVR), or Google Voice?

Once I know that, the shape is:

Incoming call → IVR consent notice → Check number against contacts/calendar → 
  Known/important → auto-notify you "Accept: [Name] calling" → you tap accept
  Unknown/flagged spam → let it ring to voicemail/decline, log number, no recording of a call you didn't take

Which telephony setup are you on? custom try…


메타데이터
post_id
db9e56e1a8ee
slug
update-ai-fraud-spam-detector-with-n8n-db9e56e1a8ee
url
https://blog.gopenai.com/update-ai-fraud-spam-detector-with-n8n-db9e56e1a8ee
canonical_url
https://blog.gopenai.com/update-ai-fraud-spam-detector-with-n8n-db9e56e1a8ee
author_url
https://medium.com/@jhparmar
status
ok
fetched_at
2026-08-05 04:13:52