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. 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 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 ; js 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 https://news.ycombinator.com/item?id=50310650 Points: 1 Comments: 0