cd /news/ai-tools/show-hn-i-m-killing-ai-slop-spam-wit… · home › topics › ai-tools › article
[ARTICLE · art-161219] src=news.ycombinator.com ↗ pub= topic=ai-tools verified=true sentiment=· neutral

Show HN: I'm killing AI slop spam with a simple Google script

A founder published a free Google Apps Script on Hacker News that moves unread Gmail messages from senders the user has never emailed into a "Review/Unknown" label and archives them, aimed at filtering AI-generated cold outreach that Google's spam filter misses. The script, which the founder said was written with Gemini's help, runs once a minute, checks up to 15 unread inbox threads per run, and calls GmailApp.markThreadUnimportant to suppress notifications; it requires enabling the setting that automatically adds email recipients to Other Contacts. The founder said he rejected Gemini's suggestion to route emails through an LLM for filtering, citing privacy and inconsistent efficacy, and acknowledged the script does not stop messages from landing in the inbox first and may over-filter time-sensitive mail.

by read3 min views1 publishedOct 30, 2026

As a founder, I've been getting an increasing amount of useless unsolicited outreach, all of which is clearly generated using AI. For some reason, Google's spam filter doesn't flag these emails as spam, so my phone buzzes throughout the day (especially in the morning) when one of these AI-generated messages arrives.

I know there are some subscription tools I could use to filter these out, and there are some friction-creating tools I can use to keep them out of my inbox (like the ones that force senders to prove they're human 1x before their emails are delivered).

But I figured there had to be a better solution that is (1) free and (2) not a hassle to people I correspond with.

After a chat with Gemini, I ended up creating a Google script that works very well for my purposes.

It simply takes any email that's in my Inbox and if it's from a sender that I've never emailed before, it moves it to a purgatory folder that I can review later. The script runs once a minute.

Pros: this is simple and deterministic. Gemini tried to get me to build a script that used AI to process emails, but I didn't want to send all my emails to an LLM, and the efficacy could vary over time, as the cat-and-mouse game of AI-spam versus AI-detection plays out.

Cons: it does not prevent emails from landing in your Inbox in the first place, possibly triggering a notification. For me, this is OK because I use the gmail app on my phone and have it set to only notify for Important emails. Gmail is pretty good at recognizing unimportant emails, so when the emails that will be filtered first land, they most likely won't trigger a notification

It's possible this will be over-inclusive, and I will be annoyed not to have seen a time-sensitive email about a conference I'm at, or some such thing. Time will tell, but so far I'm really glad to have these useless and frequent emails swept out of my Inbox.

If you have found any other free/innovative ways to get rid of AI-generated spam, please share! I'm sure there are better ideas than what I've come up with (and which Gemini wrote for me).

I've included the Google script I use below. Note that you have to turn on the option (in Settings / General) to automatically add email recipients to your Other Contacts.

Create a new script at https://script.google.com using this for the body:

  function filterUnknownSenders() {
  // Label to hold unknown emails for easy reviewing
  const LABEL_NAME = "Review/Unknown";
  let unknownLabel = GmailApp.getUserLabelByName(LABEL_NAME);
  if (!unknownLabel) {
    unknownLabel = GmailApp.createLabel(LABEL_NAME);
  }

  // Find unread messages currently sitting in your primary inbox

const threads = GmailApp.search("is:unread in:inbox", 0, 15);

  for (const thread of threads) {
    const message = thread.getMessages()[0];
    const sender = message.getFrom();
    const senderEmail = extractEmail(sender);

    // Check if you have ever sent an email to this address
    const sentHistory = GmailApp.search(`to:${senderEmail}`, 0, 1);

    // If you have NEVER emailed this person, archive and label the message
    if (sentHistory.length === 0) {
      thread.moveToArchive();
      thread.addLabel(unknownLabel);
      GmailApp.markThreadUnimportant(thread); // Prevents "Important" notifications
      Logger.log(`Archived unknown sender: ${senderEmail}`);
    }
  }

} // Helper to pull clean email address from "Name " sender strings function extractEmail(senderString) { const match = senderString.match(/<([^>]+)>/); return match ? match[1] : senderString; }

Comments URL: https://news.ycombinator.com/item?id=50310650

Points: 1

── more in #ai-tools 4 stories · sorted by recency
── more on @google 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-i-m-killing-…] indexed:0 read:3min 2026-10-30 · —