A lot of small businesses run their website enquiries through Google Forms into a Google Sheet. It's free and it works, until the same person fills the form in three times, or two people submit at the same moment and the sheet ends up with a mess of rows.
Here's a short Apps Script that keeps one row per person, counts repeat contacts, and only sends you an email for genuinely new enquiries. It needs no Zapier or Make account and no paid add-on.
The layout
Leave the "Form responses 1" tab alone. Forms writes to it directly, and it's your raw record of every submission. Add a second tab called Enquiries with these headers:
| A | B | C | D | E | F |
|---|---|---|---|---|---|
| First seen | Name | Last message | Contacts | Last contact |
The script reads each new submission and either adds a row here or updates the existing one.
In the form, set the email question's response validation to Text, then Email, so you're not matching against typos like "ann@gmail".
The script
In the sheet, open Extensions, then Apps Script, and paste this in. Change the question titles in namedValues to match your form exactly.
const SHEET_NAME = 'Enquiries'; const NOTIFY = 'you@yourbusiness.co.uk'; function onEnquiry(e) { const lock = LockService.getScriptLock(); if (!lock.tryLock(30000)) { throw new Error('Could not get the lock, submission not processed'); } try { const v = e.namedValues; const email = String((v['Email'] || [''])[0]).trim().toLowerCase(); const name = String((v['Name'] || [''])[0]).trim(); const message = String((v['Message'] || [''])[0]).trim(); if (!email) return; const sheet = SpreadsheetApp.getActive().getSheetByName(SHEET_NAME); const last = sheet.getLastRow(); const emails = last > 1 ? sheet.getRange(2, 2, last - 1, 1).getValues().map(r => String(r[0])) : []; const i = emails.indexOf(email); const now = new Date(); if (i === -1) { sheet.appendRow([now, email, name, message, 1, now]); MailApp.sendEmail(NOTIFY, 'New enquiry: ' + name, message + '\n\nFrom: ' + email); } else { const row = i + 2; const count = Number(sheet.getRange(row, 5).getValue()) || 0; sheet.getRange(row, 4, 1, 3).setValues([[message, count + 1, now]]); } SpreadsheetApp.flush(); } finally { lock.releaseLock(); } } Then add the trigger: in the Apps Script editor open Triggers (the clock icon), Add Trigger, choose onEnquiry, event source "From spreadsheet", event type "On form submit". Google will ask you to authorise it the first time.
Why the lock matters
Without LockService, two submissions that arrive a second apart can both read the Email column before either has written to it. Both see "not found" and both add a row. The script lock makes the second run wait until the first has finished. SpreadsheetApp.flush() before releasing the lock makes sure the first run's write has actually landed before the second one reads.
If the lock can't be had within 30 seconds, the script throws an error instead of guessing. The submission is still safe in the responses tab, so nothing is lost, and you can deal with it by hand.
Why lowercase and trim
People type "Ann@Example.com " on their phone one week and "ann@example.com" on a laptop the next. Lowercasing and trimming before both the write and the lookup means those land on the same row. I wouldn't go further than that. Stripping dots or plus-tags from Gmail addresses saves the odd duplicate, but it can also merge two different people at a company that uses those addresses on purpose.
Make sure you hear about failures
In the trigger settings, set "Failure notification settings" to "Notify me immediately". The default is a daily digest, which is a long time for enquiries to go quietly unprocessed. You can also see every run, and any error, under Executions in the editor.
Limits worth knowing
- MailApp has a daily recipient quota: 100 a day on a free Google account, 1,500 on Google Workspace. One notification per new enquiry is nowhere near that, but don't reuse this for newsletters.
- Reading the whole Email column on every run is fine for a few thousand rows. If the sheet gets much bigger, use a TextFinder instead: sheet.getRange('B:B').createTextFinder(email).matchEntireCell(true).findNext() returns the matching cell or null.
- Forms can't add a hidden honeypot field, so if spam becomes a problem, the simplest fix is to require sign-in to a Google account to respond. That cuts spam, but it also puts off some real customers, so it's a trade-off.
Test it before you trust it
Submit the form twice from two browser tabs as close together as you can, then once more with different capitalisation in the email. You should end up with one row, a Contacts count of 3, and one notification email. Then rename the Enquiries tab for a minute and submit again. You should get the failure email straight away, and the submission should still be sitting in the responses tab.
That's the whole thing: one tab Forms owns, one tab the script owns, a lock, and an email when something new arrives.