DEV Community

 AI Automation Enterenpeur
AI Automation Enterenpeur

Posted on

Automate Review Requests With 40 Lines of Python

Most businesses don't have a review problem. They have an asking problem. Happy clients would leave a review, but nobody asks at the right moment, and a week later it feels awkward.

Here's a small Python script that fixes that. It reads finished jobs from a CSV, emails a short review request, sends one reminder after four days, and remembers who it already contacted.

The design

  • Trigger: a job with status "done". In production this comes from your CRM or project tool (export or API).
  • Ask: one short, personal email with one link.
  • Reminder: one follow-up after 4 days, then stop.
  • State: a small JSON file so nobody gets asked twice.

The input file, jobs.csv:

id,name,email,status,reviewed
101,Dana,dana@example.com,done,
102,Lee,lee@example.com,in_progress,
Enter fullscreen mode Exit fullscreen mode

The script

import csv, json, os, smtplib
from datetime import date, timedelta
from email.message import EmailMessage
from pathlib import Path

REVIEW_LINK = "https://example.com/review"
STATE = Path("sent.json")
state = json.loads(STATE.read_text()) if STATE.exists() else {}

def send(to, subject, body):
    msg = EmailMessage()
    msg["From"], msg["To"], msg["Subject"] = os.environ["SMTP_USER"], to, subject
    msg.set_content(body)
    with smtplib.SMTP_SSL(os.environ["SMTP_HOST"], 465) as s:
        s.login(os.environ["SMTP_USER"], os.environ["SMTP_PASS"])
        s.send_message(msg)

today = date.today()
with open("jobs.csv", newline="") as f:
    for job in csv.DictReader(f):
        if job["status"] != "done" or job["reviewed"]:
            continue
        record = state.get(job["id"])
        if record is None:
            send(job["email"], "Quick favor?",
                 f"Hi {job['name']},\n\nThanks again for working with me. "
                 f"If you're happy with the result, would you leave a quick review?\n\n{REVIEW_LINK}")
            state[job["id"]] = {"asked": today.isoformat(), "reminded": False}
        elif not record["reminded"] and today - date.fromisoformat(record["asked"]) >= timedelta(days=4):
            send(job["email"], "Just a gentle nudge",
                 f"Hi {job['name']}, no pressure at all. Here's the link if you have a minute:\n\n{REVIEW_LINK}")
            record["reminded"] = True

STATE.write_text(json.dumps(state, indent=2))
Enter fullscreen mode Exit fullscreen mode

Once someone leaves a review, put anything in their "reviewed" column and the script skips them.

Run it daily

Set SMTP_HOST, SMTP_USER and SMTP_PASS as environment variables, then schedule it with cron:

0 9 * * 1-5 cd /path/to/reviews && python3 review_requests.py
Enter fullscreen mode Exit fullscreen mode

Every weekday at 9 AM it asks newly finished clients and nudges anyone who's due, exactly once.

Ideas to extend it

  • Pull jobs from your CRM's API instead of a CSV.
  • Send replies that mention a problem to yourself instead of the public review page.
  • Log each testimonial to a sheet so you can reuse it on your site and in proposals.
  • Swap the plain text for a template per client type.

Why it's worth it

It's a tiny script, but it turns a task everyone forgets into one that never gets skipped, and those reviews add up to social proof you'd never have collected by hand.

Want help building automations like this for your business? https://ai-automation-entrepreneur.vercel.app/

Top comments (1)

Collapse
 
alexshev profile image
Alex Shev •

Automating the request is helpful, but review quality improves when the request carries context that a reviewer would otherwise have to reconstruct. A compact change summary, test evidence, risk area, and explicit decision needed can reduce turnaround more than simply notifying another person sooner.