Automate Google Workspace with AI: Make Gmail, Sheets, and Calendar Do the Work
Automation that survives a shut laptop. Use AI chat to build Google Apps Script bots: a tidy inbox every morning and self-sent daily reports.

Ever bookmarked a "simple automation script" and never used it because it meant installing Python, setting up a scheduler, and leaving your laptop on all day? The problem is not your discipline. It is the container. A script that lives on your laptop only works while the laptop is awake.
The fix is to move automation into Google Apps Script: Google's free scripting platform that runs code in the cloud, right next to your Gmail, Sheets, and Calendar data. Better still, you do not need to write the code yourself. An AI chat can assemble it reliably, as long as you feed it the right context. This guide walks you from zero to two working automations: an inbox that tidies itself and a daily report that emails itself straight from a spreadsheet.
Why Apps Script Instead of a Local Script
Apps Script is a JavaScript-based platform wired directly into Google services. Three advantages make it ideal for daily automation.
First, the code runs on Google's servers. Triggers keep executing even when your laptop is off — the biggest difference from local scripts. Second, there is nothing to install: a browser and a Google account are enough; open script.google.com and you are in. Third, official bridges to Gmail, Sheets, Calendar, Forms, and Drive already exist, so tasks that normally require dozens of API lines become a few simple calls.
The trade-off is daily usage limits. For personal needs, though, those quotas are nearly impossible to hit — details at the end of this guide.
Five Minutes of Setup: Introduce AI to the Container
Before asking AI for code, prepare its home:
- Open script.google.com with your Google account.
- Click New project and rename it clearly, for example "Inbox Automation".
- Keep the Code.gs file open — that is where your code goes.
Then open your favorite AI chat and give it context. An opener prompt that works well:
I want to build a Google Apps Script automation. Context: personal Gmail
account, editor at script.google.com, a fresh empty Code.gs file.
Task: move all email from [[email protected]] into a label called
"Newsletters" and archive it so it leaves the inbox.
Give me complete code for one Code.gs file, add English comments to every
function, and explain the run steps for a beginner.
Swap in your own sender. Notice the important details: you named the platform, the account type, the file, and the desired outcome. The more specific the prompt, the fewer correction rounds you will need.
Project One: Rescue Your Inbox from Newsletter Floods
Paste the code into Code.gs, press Ctrl+S, and click Run. The first run shows Google's permission screen. Because this is your own script, it is marked "unverified" — click Advanced, choose Go to project, and grant access. You are authorizing code you can read yourself, not some third-party app.
Check the result: the "Newsletters" label appears in Gmail, and mail from that sender moves there without touching your inbox. Test with one or two senders before adding a long list.
If an error appears, do not panic. Open the Execution log under the editor, copy the error message verbatim, paste it into the AI chat, and ask for a fix. Apps Script errors are usually descriptive, so the model can almost always point to the broken line in a single round.
Add a Trigger So It Runs Every Day
A script you must click manually is only marginally better than manual work. Time to schedule it:
- Click the alarm-clock icon (Triggers) in the left panel.
- Choose Add Trigger and pick your main function.
- For the event source, select Time-driven, then Day timer — say 7–8 a.m.
From then on, the inbox tidies itself every morning without you touching anything. For tighter intervals — checking mail every 15 minutes, for instance — pick Minutes timer in the same menu.
About quotas: personal accounts get roughly 90 minutes of total trigger runtime per day. An inbox cleaner touches two or three seconds per run, so that allowance feels endless.
Level Up: A Daily Report from Spreadsheet to Email
The same pattern unlocks something far more interesting: reports that write themselves. Say you log transactions in Google Sheets and want a daily recap in your inbox at 6 p.m. Here is the prompt:
Write a Google Apps Script that:
1. Reads the sheet named "Rekap" from the spreadsheet with ID [SPREADSHEET_ID].
2. Pulls today's rows from column A (date) and column B (amount).
3. Totals today's amounts.
4. Emails a summary to [[email protected]] every day at 18:00 using a
Time-driven trigger.
5. If there are no transactions today, send a short email saying
"No transactions today."
Use SpreadsheetApp and MailApp. Include English comments.
Once the code is pasted and the trigger is set as in the previous section, your spreadsheet becomes a reporting employee who never misses a deadline. The pattern adapts easily: form-response recaps, new-row notifications, or deadline reminders from a planning sheet.
The Prompt Framework That Rarely Fails: Six Facts to Include
Both examples share a reusable pattern. A prompt for any Apps Script job should always contain:
- The platform and account type: Apps Script, personal or Workspace account.
- The goal in one measurable sentence.
- The services involved: Gmail, Sheets, Calendar, Forms, or Drive.
- The label names, sheet names, or spreadsheet IDs being used.
- The execution schedule you want.
- Edge cases: what if the data is empty, the sender is missing, or the column format changes.
Two small habits also save hours. Ask the AI to comment the code — six months from now you will be grateful you can still read what each function does. And change exactly one thing per iteration; stacking three requests at once makes it hard to trace which change broke the script.
Limits, Security, and Common Sense
Three final notes before you automate everything. First, know the boundaries: beyond the daily trigger allowance, personal accounts may email about 100 recipients per day through scripts, and a single execution stops at six minutes. For personal-scale reports and cleanups, all of that is generous.
Second, stay safe. Read AI-generated code before approving the permission screen — make sure it only asks for access relevant to the task. Never paste real sensitive data into prompts; use dummy data and a test spreadsheet until the script proves stable.
Third, start small. One script, one trigger, one week at a time. Once your first two automations run smoothly, expand to Calendar for meeting reminders, Forms for signup notifications, or Drive for automatic archiving. Your workspace slowly turns into an office that does its own chores — and you get to focus on the work that genuinely needs a human.
References
- Google Apps Script Official Documentation — guides, service reference, and sample code.
- Understanding Apps Script Triggers — the official guide to simple and installable triggers.
- Apps Script Service Quotas — daily limits for email, triggers, and executions per account type.
- Apps Script Dashboard — all your projects and execution logs in one place.



