The Problem with Manual Order Checking
As the business grows, over 100 orders enter Google Sheets every day. Sometimes buyers place duplicate orders for the same product, making it difficult to determine if it's an intentional reorder or an accidental double-click. Manual verification consumes enormous time, and fatigue often leads to missed duplicates.
One day a complaint email arrived from a buyer. They said we were shipping the same order content they'd already received. That's when we discovered the duplicate order, and we had to process a refund.
Building a Duplicate Detection Bot with Claude Code
Step 1: Prepare Order Data
Assume the Google Sheets contains the following information.
Order ID | Buyer Name | Product | Quantity | Order Date | Status
001 | ABC Co | Shirt | 100 | 2024-01-15 | Pending
002 | ABC Co | Shirt | 100 | 2024-01-15 | Pending
003 | DEF Ltd | Pants | 50 | 2024-01-15 | Shipped
Step 2: Write Claude Code Script
Build the following logic using Python.
import pandas as pd
from datetime import datetime, timedelta
# Load Google Sheets data
df = pd.read_csv('orders.csv')
# Filter orders from the last 24 hours
today = datetime.now()
df['order_date'] = pd.to_datetime(df['order_date'])
recent_orders = df[df['order_date'] > today - timedelta(days=1)]
# Duplicate detection: same buyer + same product + same quantity
duplicates = []
for buyer in recent_orders['buyer_name'].unique():
buyer_orders = recent_orders[recent_orders['buyer_name'] == buyer]
for product in buyer_orders['product_name'].unique():
product_orders = buyer_orders[buyer_orders['product_name'] == product]
if len(product_orders) > 1:
duplicates.append({
'buyer': buyer,
'product': product,
'count': len(product_orders),
'order_ids': product_orders['order_id'].tolist()
})
# Generate alert
if duplicates:
alert_message = f"Found {len(duplicates)} duplicate orders!\n"
for dup in duplicates:
alert_message += f"- {dup['buyer']}: {dup['product']} ({dup['count']} orders)\n"
print(alert_message)
else:
print("No duplicate orders")
Step 3: Set Up Automated Execution
On your Windows device, use Task Scheduler to run this script daily at 9 AM.
• Program: `python.exe`
• Arguments: `C:\\automation\\duplicate_check.py`
• Frequency: Daily at 9 AM
Real Results
Three weeks after implementing the bot:
• Duplicate orders detected: 7
• Time saved: 15 minutes daily (manual) → 30 seconds (bot)
• Disputes caused by duplicates: 0
The best part is that orders arriving late at night get checked automatically. By morning, the duplicate list is already organized and waiting.
Extra Tip: Connect to Notification Channels
For faster response, send alerts directly to Discord or Slack.
import requests
# Discord Webhook URL
WEBHOOK_URL = "https://discord.com/api/webhooks/..."
if duplicates:
message = f"Found {len(duplicates)} duplicate orders!\n"
for dup in duplicates:
message += f"{dup['buyer']} - {dup['product']}\n"
requests.post(WEBHOOK_URL, json={"content": message})
Conclusion
Duplicate order detection is a small but effective automation solution. By delegating repetitive work that humans easily miss to a bot, your team can focus on truly important tasks.