Section 8: Google Workspace + Gemini integration scenarios

Scenario 78: Custom report automation with Apps Script and Gemini

Level: Advanced · Tools: Google Apps Script, Vertex AI service, Agent Platform API, Gemini model, Google Cloud

Who and in what situation

Okan is an operations analyst at a logistics company. He wants to generate a weekly explanation of delays that fits the company’s Sheets and Docs workflow and goes beyond what the standard Workspace buttons provide.

How it is done today

Okan downloads the spreadsheet, copies the data into a separate AI tool, and pastes the resulting text into the report file.

How to do it with AI

  1. Create or select a Google Cloud project and enable billing for the project. This is a prerequisite for the Apps Script Vertex AI service. [140]
  2. Enable Agent Platform API in Cloud Console. The document explains that this API is also referred to by its previous name, Vertex AI API. [140]
  3. Enable Vertex AI service in the Apps Script project. Use the callVertexAI function in Google’s example as a starting point and change the prompt, region, project ID, and model name according to your organization’s standards. [140]
  4. Generate the output using only the selected data range. For example, have each delay row summarized under the headings cause, evidence, and follow-up recommendation.
  5. Review the log output and model response on the first run.

Example prompt

Review the delay records in {sheet_range}. For each record, produce the headings cause, substantiated information, and point requiring human verification, based only on the available data. Do not guess missing values.

Evidence and real-world example

The Google Developers document states that the Vertex AI service in Apps Script can make generateContent calls to Gemini and provides sample code; this technical document is the basis for this scenario. [140]

Points to consider

A Cloud project with billing disabled, an API that has not been enabled, or a service that has not been enabled in Apps Script will prevent the workflow from running. [140] Do not assume that a Vertex AI API call is covered by the same commitments as Gemini within Workspace; obtain organizational approval for data classifications and access permissions. Read the data terms for Gemini within Workspace separately. [40] Do not write API keys or service account secrets into the code.

Sources for this scenario

  1. Google Workspace Gemini veri koruması (support.google.com)
  2. Vertex AI Service in Apps Script (developers.google.com)