Google Workspace

Can Gemini Write Google Apps Script for You? A Beginner's Guide to Workspace Automation

Learn how to use Gemini in the Google Apps Script editor to create, understand, test and improve simple Google Workspace automations, even if you are not a programmer.

You probably have repetitive tasks in Google Workspace that take more time than they should. Perhaps you copy information from Google Forms into a spreadsheet, send the same follow-up email every week, create documents from a template or remind colleagues about outstanding tasks.

Google Apps Script can automate many of these activities. The challenge for beginners is knowing how to write the code.

That is where Gemini in the Apps Script editor can help.

Google has made the Gemini side panel in the Apps Script editor generally available. You can describe an automation in plain language and ask Gemini to generate, explain, modify or troubleshoot the code. You do not have to begin with a blank editor or understand every line before you start.

But there is an important distinction: Gemini can help you write a script. It does not remove your responsibility to review, test and secure the automation before using it with real business data.

This guide explains how to get started and how to use Gemini responsibly.

What is Google Apps Script?

Google Apps Script is a cloud-based scripting platform that lets you customise and connect Google Workspace applications.

It can work with tools such as:

  • Google Sheets
  • Google Docs
  • Google Forms
  • Gmail
  • Google Calendar
  • Google Drive
  • Google Slides

For example, a business could use Apps Script to send an email when a Form is submitted, create a Google Doc from spreadsheet information, generate Calendar events or send reminders when a deadline approaches.

Apps Script is especially useful when the same task is repeated and the steps can be clearly defined.

What can Gemini do inside the Apps Script editor?

The Gemini side panel can help you move from an idea to a script. You can ask it to:

  • Generate a new script from a plain-language description.
  • Explain what an existing function does.
  • Modify a script to add a new feature.
  • Help identify and fix errors.
  • Suggest ways to improve the structure of your code.
  • Explain Apps Script concepts you do not understand.

For example, instead of searching for a script and trying to adapt it, you can describe the exact workflow you want.

Gemini can use context from the active script project to make its suggestions more relevant. It also presents proposed code changes for review, so you can inspect suggestions before accepting them.

What do you need before using Gemini in Apps Script?

You need access to the Apps Script editor and an eligible Google account or licence.

Availability depends on the account or subscription. Supported options include certain Google Workspace Business and Enterprise editions, eligible Gemini add-ons and Google AI plans. For a work or school account, your administrator may also need to enable Gemini features.

If you do not see the Gemini side panel, it does not automatically mean your account is broken. Your edition, administrator settings or rollout status may affect availability.

You can open Apps Script in any of these ways:

  1. Open a Google Sheet, Doc, Slide or Form.
  2. Select Extensions.
  3. Choose Apps Script.

You can also open the Apps Script editor directly and create a new project.

In the editor, look for the Gemini sparkle icon in the side panel. Select it to open the prompt area.

How to create your first automation with Gemini

Let's use a practical example.

Imagine you manage registrations for a training programme. People submit a Google Form, and you want an email notification whenever a new response arrives.

Before asking Gemini to write code, define the workflow.

Step 1: Describe the task clearly

A weak prompt would be:

"Write a script for my Google Form."

That does not explain what the script should do, where the data is stored or who should receive the notification.

A stronger prompt would be:

I have a Google Form connected to a Google Spreadsheet. Write a Google Apps Script that sends an email notification to admin@example.com whenever a new form response is submitted. The email should include the respondent's name, email address and programme selected. Use the spreadsheet form-submit event trigger. Add comments explaining the code and include instructions for setting up the trigger. Do not send emails when the required name or email fields are empty.

The more specific your instructions, the more useful the generated code is likely to be.

Step 2: Review the generated code

Do not accept every suggestion automatically.

Read the script and check:

  • Does it use the correct event trigger?
  • Does it refer to the correct spreadsheet or Form fields?
  • Are the email recipients correct?
  • Does it handle missing information?
  • Does it send only the notifications you intended?
  • Does it perform any action you did not request?

If you do not understand a section, ask Gemini to explain it in plain language before accepting it.

Step 3: Ask Gemini to improve the script

You can continue the conversation with a specific instruction.

For example:

Explain what each function does and identify any risks if the Form receives duplicate submissions.

Or:

Add error handling so the script records failures in the execution log. Do not change the existing email content or recipient.

This is a better approach than asking Gemini to rewrite the entire project every time you want one improvement.

Step 4: Test with sample information

Create a test Form response using information you control. Confirm that:

  • The response reaches the linked spreadsheet.
  • The script runs successfully.
  • The notification goes to the correct address.
  • The message contains the correct information.
  • Missing or invalid information is handled as expected.

Check the Executions section in Apps Script if the automation fails. The error message can help you identify what needs attention.

Step 5: Set up the trigger

Some scripts run only when you execute them manually. Others need an event trigger.

For the example above, create an installable trigger:

  1. Open the Apps Script project.
  2. Select Triggers from the left sidebar.
  3. Click Add Trigger.
  4. Select the function that sends the notification.
  5. Choose From spreadsheet as the event source.
  6. Choose On form submit as the event type.
  7. Save the trigger and complete the authorisation process.

The function must be written to handle the event object supplied by the spreadsheet form-submit trigger. Simply creating a trigger does not make an unrelated function work correctly.

Five useful prompts to try in Apps Script

You can use the same approach for many everyday workplace tasks.

1. Send reminders for overdue tasks

I have a Google Sheet with columns for Task, Assigned To, Email Address, Due Date and Status. Write a Google Apps Script that checks for overdue tasks every morning and emails the assigned person if the status is not Completed. Prevent the same person from receiving repeated reminders for the same task on the same day. Explain the required time-driven trigger.

2. Create Google Docs from spreadsheet records

I have a Google Docs template and a Google Sheet containing employee information. Write a script that creates a copy of the template for each new employee record, replaces the placeholders with the correct spreadsheet values and saves the document in a specified Google Drive folder. Do not share the documents automatically. Explain how to configure the template and folder IDs.

3. Generate a weekly report

Write a Google Apps Script that reads the current week's records from my Google Sheet, summarises the totals by category and creates a formatted Google Doc report. Explain how the script identifies the date range and how I can schedule it to run weekly.

4. Create Calendar events from a spreadsheet

My Google Sheet contains Event Title, Date, Start Time, End Time and Description. Write a script that creates Google Calendar events from rows that have not yet been processed. Add a column to record the event ID so the script does not create duplicate events when it runs again. Explain how to test it safely.

5. Clean and standardise spreadsheet data

I have a Google Sheet containing names, email addresses and phone numbers. Write a script that trims unnecessary spaces, standardises email addresses to lowercase and flags incomplete records in a separate Status column. Do not delete any rows or overwrite the original values without first explaining the changes.

These prompts are starting points. You must adjust the column names, file locations, recipients and business rules to match your own Workspace setup.

Important: Do not trust generated code without testing it

AI-generated code can contain errors, make incorrect assumptions about your spreadsheet structure or request more permissions than the task requires.

Before using a script in a live organisation:

  • Test it with a copy of the spreadsheet or sample records.
  • Check every recipient, file ID and folder ID.
  • Review the permissions requested during authorisation.
  • Confirm that the trigger runs under an appropriate account.
  • Check what happens when a record is missing, duplicated or incorrectly formatted.
  • Keep a backup of important data before running scripts that modify files or records.
  • Review execution logs after testing and during maintenance.

Remember that Apps Script runs with the permissions of the account authorising it. A script should not be given access to information or actions that its task does not require.

For organisations, administrators should also consider who owns the script, who can edit it and what happens if the owner leaves the organisation.

Does this mean you no longer need to learn coding?

No. Gemini lowers the barrier to writing code, but understanding the workflow is still essential.

You need to know what should trigger the automation, what information it should use, what action it should perform and how to recognise when something goes wrong.

A person who understands Google Forms, Sheets, Drive permissions, triggers and basic workflow logic will get more reliable results from Gemini than someone who simply copies code without understanding it.

The strongest approach is to use AI as an assistant, not as a substitute for technical judgement.

Final thoughts

You do not have to become a professional developer before you start automating everyday Google Workspace tasks. Gemini in Apps Script gives beginners a way to describe what they want to achieve and work through the code with assistance.

Start with one repetitive task. Define the process, generate a script, review the suggestions, test with sample data and only then introduce it into your actual workflow.

If you want to build a stronger foundation in Google Workspace and learn how to use its tools confidently in real workplace situations, explore the FTHS Google Workspace Mastery Course. The course focuses on practical skills you can apply to everyday administrative and business tasks.

Success Agbeyegbe
Success Agbeyegbe

Founder of First Tech Hub Solutions. Success helps graduates, virtual assistants and early career professionals build practical digital skills with Google Workspace, freelancing on Upwork and remote work.

Link copied