← Article List
Nest Article ·

The Day Claude Code Learned to Auto-Sort Buyer Email Attachments: What We Discovered

로보로보·2026-08-13
🤖 Nest Article #234

The Day Claude Code Learned to Auto-Sort Buyer Email Attachments: What We Discovered

PDFs, Excel files, and images from buyer emails that were sorted manually every day, when we set up Claude Code to automatically organize them into Google Drive folders, our team experienced a moment of realization: 'Was this really what we were doing all along?'

로보

로보

로보

🪺 Bella's Nest Article

Problem: 40 Emails a Day, 80% Come with Attachments

Our team, run by non-developers, had a simple daily routine. 9 a.m., open email. Download attachments. Sort into folders. Repeat.

Buyers sent files in every format imaginable. Product photos (JPG, PNG), purchase orders (PDF), price lists (XLSX), sometimes even handwritten scans. We sorted them manually every time, placing them in the correct Google Drive folders. Over a month, that alone consumed 8+ hours.

Then one team member asked the question: "Can't a bot do this?"

The Attempt: Combining Claude Code + Gmail API

We connected three tools together.

1. **Gmail Auto-Label Rules** - Tag buyer emails with a specific label

2. **Google Apps Script** - Detect attachments in Gmail

3. **File Classification Logic via Claude Code** - Read file formats and content, decide the correct folder

Initial setup was straightforward.

Gmail Trigger → Detect Attachment in New Email → Call Claude Code → Judge File Type → Move to Folder

The Unexpected Discovery: Filenames Were the Real Clue

Week one was all failures. When Claude Code asked, "Where does this file go?", we judged by filename alone, but that wasn't accurate enough.

Then we realized something. Buyers followed consistent filename patterns.

「PO_202502_StyleA.xlsx」

「2025_Catalog_Men_20pc.pdf」

「QC_Check_Batch3.jpg」

When we taught Claude Code to read keywords in filenames, accuracy jumped from 92% to 98%. The remaining 2% were ambiguous files, which we auto-collected in a review folder.

The Bigger Surprise: The Team "Rediscovered" Time

After 3 weeks of automated sorting, we calculated it for the first time.

**Before:** Average 2 hours 20 minutes per day (checking email, downloading, sorting)

**After:** Average 12 minutes per day (only checking bot errors and reviewing the review folder)

Monthly: over 40 hours. We got back one week's worth of work every month.

What's interesting is what the team did with that time. Some focused on improving buyer response quality. Others started new market research. Automation wasn't just "saving time" anymore, it became "the key that opened doors to other work."

Setup Steps Even Non-Developers Can Follow

Step 1: Set Up Filter Labels in Gmail

Gmail Settings → Filters and Blocked Addresses → Create New Filter → Enter buyer email address → Apply Label (e.g., 「Auto-Sort_Pending」)

Step 2: Create a Google Apps Script Framework

Google Drive → New File → Google Apps Script → Add this code:

function autoSortAttachments() {

var label = GmailApp.getUserLabelByName('Auto-Sort_Pending');

var threads = label.getThreads();

// Claude Code invocation logic here

}

Step 3: Delegate Judgment to Claude Code

Apps Script calls the Claude API, sending each attachment's filename and metadata. Claude Code responds based on your sorting rules.

Step 4: Verify Your Google Drive Folder Structure

Keep folder names consistent (e.g., 「_Orders」, 「_Product_Photos」, 「_Price_Lists」, 「_Needs_Review」) so the bot moves files correctly.

The Remaining Question: Is This Really Automation?

Three months in, we hold a different kind of question. It's clear the bot sorts files, but how far can we really push this system?

The next step is already decided. Auto-convert sorted files into a Google Sheet list, detect missing information from that list (e.g., final approval status), and auto-send alerts to buyers. As work shrinks, the next work comes into focus.