Two requests in the same second
Each run takes a script lock first, so two submissions can't grab the same row or reference number. If the lock can't be had in 30 seconds, the request is written to the Log tab instead of dropped.
LockServiceForm → Sheet → Email automation · Google Apps Script
A made-up mover, Copperwick Moving Co., gets quote requests from a Google Form and from its website. This is the automation I'd set up for it: every request lands in one Google Sheet with a reference number, goes to the right estimator by town, and the customer gets a confirmation straight away. Repeats, typos and spam get caught, and if a request sits unanswered, someone hears about it.
01 · How it works
Each step is a small plain-JavaScript function in Rules.gs. The part that talks to Google (reading the sheet, sending mail) is kept separate in Code.gs, so the rules can be tested without a Google account, and the "Try it" box below runs the exact same file.
From a Google Form linked to the sheet, or the website's own form posting to the script.
A hidden field only bots fill in, and a limit on links in the notes. Spam is logged, never emailed.
Email format, common domain typos like gmial.com, phone length, a sane move date.
Same email or phone with an open request in the last 14 days? Update that row instead of adding one.
The town they're leaving picks the area and estimator. Long-distance moves go to one person.
Moving within 7 days is Rush. The reply-by time counts business hours only, Mon to Sat, 8 to 6.
One row on the sheet, an alert to the estimator, a confirmation to the customer.
Then, on a timer
02 · Try it
This runs Rules.gs and Emails.gs in your browser against a copy of the sheet. Nothing is sent anywhere: the emails are shown here instead. Pick an example or fill it in yourself.
Emails the script would send show up here.
03 · The sheet
The office works in the Requests tab and updates the Status column. Who covers which town, office hours, the reply window and the rush cutoff all live in tabs anyone can edit.
04 · The emails
The customer gets the details back and a name and time to expect a call. The estimator gets everything needed to phone them, with Rush and anything to double-check at the top. Each email has a plain-text version too.
05 · Follow-up
Two time-driven triggers do the chasing, so nobody has to remember to check the sheet.
A request that gets missed · one Tuesday
06 · Edge cases
Most small automations work on the happy path and break quietly on everything else. These are the cases I planned for. Each is handled in the code and checked by the tests in the repo, using stand-ins for Google's services.
Each run takes a script lock first, so two submissions can't grab the same row or reference number. If the lock can't be had in 30 seconds, the request is written to the Log tab instead of dropped.
LockServiceApps Script can email 100 recipients a day on a free Google account and 1,500 on Workspace. The script checks what's left before every send; if it's out, the row is still saved and the skip goes in the Log.
getRemainingDailyQuota()Columns are matched by header text, not position, so dragging "Phone" next to "Name" or adding a "Crew" column doesn't send data into the wrong place.
readRequests_()Any error is caught, the full request is saved to the Log with the error, and the office gets an email saying so. The customer's details are never only in a failed run.
handleRequest_()grace@gmial.com would bounce. The row is marked Check contact and the estimator is told, but no confirmation goes to the bad address.
validateRequest()People resubmit when they don't hear back. The second one updates the first row (new date, extra notes, a repeat count) and pings the estimator instead of making a second lead.
findDuplicate()07 · Setup and handoff
The script runs in the business's own Google account. No outside service, no monthly plan, nothing that stops working if I disappear.
FORM_FIELDS if yours differ.Code.gs, Rules.gs and Emails.gs.setup() once and accept Google's permission prompt. It creates the three triggers and the Status dropdown.var dup = findDuplicate(req, ctx.rows, now, cfg); if (dup) { var prev = dup.row; step('Duplicate check', 'Same ' + dup.on + ' as ' + prev.ref + ' (' + prev.status + '). Added to that row instead of making a new one.', 'warn'); var merged = mergeIntoRow(prev, req, now, check); step('Sheet', 'Updated ' + prev.ref + ': repeat count ' + merged.repeats + ', newest details kept'); if (prev.estimatorEmail) { emails.push({ to: prev.estimatorEmail, kind: 'repeat', ref: prev.ref }); step('Email', 'Heads-up to ' + prev.estimator + ': this person asked again', 'mail'); } step('Customer email', 'Not sent again (they already have ' + prev.ref + ')', 'skip'); return { outcome: 'merged', row: merged, index: dup.index, emails: emails, log: log }; } step('Duplicate check', 'No open request with this email or phone in the last ' + cfg.duplicateDays + ' days');
✔ setup makes the tabs, headers, status dropdown and three triggers ✔ columns are found by header, even after someone moves them ✔ when the email quota is used up the row is still saved and the skip is logged ✔ the morning digest goes to the office ✔ if the lock is busy for 30 seconds, the request goes to the Log instead of being dropped ✔ a long-distance move goes to the long-distance person ✔ an unknown town goes to the office and is noted ✔ a broken email is held too ✔ past and far-out move dates are noted but still logged ✔ the same person again updates their row instead of adding one ✔ duplicates match on phone too, but not closed or old rows ✔ emails escape whatever people type … 21 more ℹ tests 33 · pass 33 · fail 0
Built and tested offline against stand-ins for Google's services (the tests are in the repo). It hasn't been installed for a real business, and no real email was sent.