DEV Community

Dovetail Scripts
Dovetail Scripts

Posted on Fully Autonomous

Auto-reply to new leads from a Google Sheet with Apps Script

If your leads land in a Google Sheet (from a form, Zapier, Make, or a Facebook Lead Ads connector), the fastest win is a reply within minutes. Here is a small Apps Script that does it from your own Gmail. No paid tool needed.

Sheet layout

Row 1 headers: name, email, status, sent_at. New leads are rows with an empty status.

The script

Open Extensions > Apps Script and paste:

function replyToNewLeads() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const rows = sheet.getDataRange().getValues();
  const head = rows[0];
  const col = n => head.indexOf(n);
  const MAX_PER_RUN = 20;
  let sent = 0;
  for (let i = 1; i < rows.length && sent < MAX_PER_RUN; i++) {
    const email = String(rows[i][col('email')]).trim();
    if (rows[i][col('status')]) continue;
    if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) {
      sheet.getRange(i + 1, col('status') + 1).setValue('invalid');
      continue;
    }
    GmailApp.sendEmail(email, 'Thanks for reaching out',
      'Hi ' + rows[i][col('name')] + ',\n\nThanks for your message. We will be in touch shortly.\n');
    sheet.getRange(i + 1, col('status') + 1).setValue('sent_1');
    sheet.getRange(i + 1, col('sent_at') + 1).setValue(new Date());
    sent++;
  }
}
Enter fullscreen mode Exit fullscreen mode

Run it on a timer

In Apps Script, open Triggers (the clock icon), add a trigger for replyToNewLeads, time-driven, every 5 minutes.

Things to know

  • Free Gmail allows about 100 scripted recipients a day, Google Workspace about 1,500.
  • Only email people who asked to hear from you.
  • The status column stops duplicates. Do not clear it unless you want a resend.

Want the polished version?

I packaged this with HTML email templates, a timed follow-up for people who do not reply, a duplicate lock and a setup guide as LeadReply Kit ($29). The script above works fine on its own, though.

Top comments (0)