Every online store gets the same email on repeat, and Black Friday week is the worst: "Hi, where's my order?"

Each reply takes the same steps: find the order number, look it up, paste the tracking link. That makes it a perfect first automation. In this post we'll build a small Python script that reads incoming messages, matches order numbers against an orders CSV, and drafts a reply, or flags the message for a human.

The plan

  1. Load orders from a CSV export from your store.
  2. Pull an order number out of each email with a regex.
  3. Look the order up.
  4. If it has shipped, draft a friendly reply with tracking.
  5. Otherwise, return a reason so a human can take it.

The data

Here's a minimal orders.csv:

order_id,first_name,carrier,ship_date,tracking_url 104233,Dana,UPS,2026-11-28,https://example.com/track/1Z999 104240,Luis,USPS,, 

The script

import csv import re ORDER_RE = re.compile(r"#?(\d{5,7})") def load_orders(path): with open(path, newline="") as f: return {row["order_id"]: row for row in csv.DictReader(f)} def draft_reply(email_text, orders): match = ORDER_RE.search(email_text) if not match: return None, "no order number" order = orders.get(match.group(1)) if not order: return None, "order not found" if not order["tracking_url"]: return None, "not shipped yet" reply = ( f"Hi {order['first_name']},\n\n" f"Thanks for your order #{order['order_id']}! " f"It shipped on {order['ship_date']} with {order['carrier']}.\n" f"Track it here: {order['tracking_url']}\n\n" "Just reply if anything looks off and a real person will jump in." ) return reply, "ok" if __name__ == "__main__": orders = load_orders("orders.csv") inbox = [ "Hi, where is my order #104233? Thanks!", "Any update on 104240?", "Can I change my shipping address?", ] for msg in inbox: reply, status = draft_reply(msg, orders) print(f"[{status}]") print(reply or f"-> route to human: {msg}") print("-" * 40) 

Running it prints one drafted reply and two messages routed to a human, each with a reason.

Why return a status?

The status string is the safety valve. Anything that isn't ok goes to a person. In production you'd also route by tone: refund requests, complaints and all-caps messages should never get an automated reply.

Taking it further

Connect a real inbox: poll IMAP or use your help desk's API instead of the hard-coded list.
Use live data: swap the CSV for your store's orders API.
Handle messy messages: when the regex finds nothing, ask an LLM to pull out the order number or customer email, then fall back to the lookup.
Draft, don't send, at first: save replies as drafts for a week, review them, then turn on auto-send for the ok cases.
Log everything: write each message, status and reply to a sheet so you can measure how much time you saved.

Wrap-up

Start with your most repeated support question. For most stores it's this one. Forty lines of Python won't replace your support team, but it can clear the routine work so they can focus on customers who need them.

Need help building this into a production workflow? https://ai-automation-entrepreneur.vercel.app/