Blog / Build with AI /

Google Apps Script plus AI: automations for small teams

Small teams run on spreadsheets. An order list in Sheets, a content calendar in Sheets, a sign-up form that drops its answers into Sheets. And then somebody has to copy things, send reminders, move rows and tidy up, every day, by hand.

Google Apps Script is the built-in way to stop doing that. It’s a small programming environment that lives inside your Google account, free to use, and it can read and write Sheets, send email, create calendar events and talk to other services. It uses JavaScript, which AI assistants write fluently.

That combination is why it’s one of the best places for a non-developer to start building with AI: no servers, no installs, no hosting, and the data is right there.

What Apps Script can do for a small team

Real examples of the kind of job it suits:

  • Email a daily summary of rows marked “Open” to the team
  • Colour or flag rows that haven’t been updated in a week
  • Copy new form responses into a tidy tracking sheet
  • Create a calendar reminder for each new deadline in a list
  • Move finished rows to an “Archive” tab
  • Turn a sheet of text into a set of Google Docs

None of this needs a database or a developer. It needs a clear description of what should happen.

Getting to the editor

Open a Google Sheet. In the menu choose Extensions → Apps Script. A code editor opens in a new tab with an empty function. That’s your workspace. Scripts you write there are bound to that spreadsheet.

You’ll also see a clock icon on the left. That’s Triggers, which is how a script runs on a schedule. We’ll use it shortly.

A first automation: a daily email of open items

Say you have a sheet called Orders. Column A is the order ID, column B is the customer name, and column D is a status such as Open or Done. You want one email each morning listing the open ones.

Here’s the prompt:

I’m using Google Apps Script bound to a Google Sheet. The sheet “Orders” has a header row. Column A is order ID, column B is customer name, column D is status. Write a function that collects all rows where column D is “Open” and emails a plain-text list (ID and name per line) to team@example.com with the subject showing how many are open. If none are open, send nothing. Don’t change the sheet. Explain how to run it and how to schedule it.

A correct answer looks close to this:

function sendOpenOrders() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Orders');
  const rows = sheet.getDataRange().getValues().slice(1); // skip header
  const open = rows.filter(function (row) { return row[3] === 'Open'; });

  if (open.length === 0) return;

  const body = open.map(function (row) { return row[0] + ' - ' + row[1]; }).join('\n');
  MailApp.sendEmail('team@example.com', open.length + ' open orders', body);
}

Note a few things to check, because this is the part you’ll repeat for every script:

  • Arrays start counting at zero, so column D is row[3]. Off-by-one slips are the most common bug.
  • The slice(1) skips the header row.
  • It reads and emails. It never edits or deletes anything. That’s the safest kind of first script.
  • The sheet name is spelt exactly as it appears on the tab.

Paste it in, save, and press Run.

The permission prompt

The first time you run it, Google asks you to authorise the script. This is where you slow down. The dialog lists what the script can access: your spreadsheets, your email-sending ability. Read it. If a simple “tidy my rows” script asks to read all your Drive files or manage your email, something is off, so ask the AI why before you continue. You may see an “unverified app” warning. For your own script, that’s expected, but you should still know exactly what you are granting.

Scheduling it

  1. Click the clock icon (Triggers).
  2. Choose Add Trigger.
  3. Pick your function, sendOpenOrders.
  4. Event source: Time-driven. Choose a daily timer and a time window.
  5. Save.

Check that the timezone setting in the project matches yours, or your “8 a.m.” email will arrive at a strange hour. The trigger also runs as you, so if you leave the team, the automation goes with your account. For anything that matters, note who owns it.

How to prompt for scripts so they work

A few habits make the difference:

  1. Name the sheet and the columns. The AI can’t guess them.
  2. Say what the script must not do. “Don’t delete rows” and “don’t change the original sheet” are your safety net.
  3. Ask for a test mode. “Add a variable DRY_RUN that logs what it would do instead of doing it.” Run in dry-run mode first.
  4. Ask for comments on each step in plain English.
  5. Ask for logging. console.log or Logger.log lines show what happened, and they’re where you look when something fails. Open Executions in the editor to see runs and errors.

A prompt for the “test mode” idea:

Add a DRY_RUN constant at the top. When it’s true, log the email body instead of sending it.

When it breaks

Scripts fail in predictable ways.

  • “Cannot read properties of null”: usually a sheet name typo, so getSheetByName returned nothing.
  • Nothing happens: the status text doesn’t match exactly (Open vs open vs Open with a trailing space).
  • Authorisation needed: you changed what the script does and it now needs a new permission.
  • Quota errors: Google limits how many emails a script can send per day and how long it can run. A script that loops over thousands of rows may hit the time limit and stop.

When you ask the AI for help, give it the exact error message and the relevant lines of code, not “it doesn’t work”. That habit is worth its own post.

Safety rules for a team

Small teams have no IT department, so make some rules up front.

  • Keep a copy of the sheet before testing anything that edits data. Version history helps, but a duplicate is faster to restore.
  • Name the owner of each script in a note on the sheet.
  • Don’t put secrets (API keys, passwords) in the script text, because anyone with edit access can read it. If you need to store one, look at the Script Properties setting. The basics of why are in what an API key is and why you should never share it.
  • Limit who can edit the sheet. Edit access to the sheet often means edit access to the bound script.
  • Don’t automate decisions. Automate the boring copying and reminding. Leave judgement to people. I wrote about this line in when automation is not worth it.

Key takeaways

  • Apps Script lives inside Google Sheets (Extensions → Apps Script) and is free to use.
  • AI writes it well when you describe the sheet: names, columns, rules, and what not to do.
  • Start with read-and-notify scripts, not delete-and-edit ones.
  • Read the permission prompt before you authorise anything.
  • Schedule with triggers, and know who owns the automation.
  • Test with a dry run and a copy of the data.

FAQ

Do I need to know JavaScript?

Not to start. You need to read it well enough to see which sheet and which columns it touches. You’ll pick up the rest.

Is it free?

Apps Script is included with a Google account, within daily quotas. Limits can be lower on free accounts than on paid Workspace ones.

Can it replace tools like Zapier?

For jobs inside Google’s tools, often yes. For connecting many different apps without code, a dedicated automation service is easier.

What is the one thing in your team’s spreadsheet that someone copies by hand every week? Describe it in three lines to an AI and ask for a dry-run version first.