AppsScriptPulse

Nano Steps, Giant Leaps: Exploring On-Device AI in Chrome for Workspace Editor Add-ons

The landscape of what’s possible within the browser is quietly undergoing a significant shift, and for Google Workspace Add-on developers, this could be a game-changer. Chrome’s AI mission is simple yet powerful: to ‘make Chrome and the web smarter for all developers and all users.’ We’re seeing this vision begin to take shape with the emergence of experimental, built-in AI APIs in Google Chrome, designed to bring powerful capabilities using models like Gemini Nano directly to the user’s device.

There is a growing suite of these on-device APIs. This includes the versatile Prompt API, specialised Writing Assistance APIs (like Summarizer, Writer, and Rewriter), Translation APIs (Language Detector and Translator), and even a newly introduced Proofreader API. For many existing Workspace Add-on developers, some of the more task-specific APIs could offer a relatively straightforward way to integrate AI-powered enhancements.

However, my focus for this exploration, and the core of the accompanying demo Add-on being introduced here, is the Prompt API. What makes this API particularly compelling for me is its direct line to Gemini Nano, a model that runs locally, right within the user’s Chrome browser. This on-device approach means that, unlike solutions requiring calls to external third-party GenAI services, interactions can happen entirely client-side. The Prompt API provides web applications, including Google Workspace Editor Add-ons, with an open-ended way to harness this local AI for text-based generative tasks.

To put the Prompt API’s text processing abilities through its paces in a practical Workspace context, I’ve developed a Google Workspace Add-on focused on text-to-diagram generation. This post delves into this demonstration and discusses what on-device AI, through the versatile Prompt API, could mean for the future of Workspace Add-on development, including its emerging multimodal potential.

Why This Matters: New Horizons for Google Workspace Developers

Using an on-device LLM like Gemini Nano offers several key benefits for Workspace Add-on developers:

  • Enhanced Data Privacy & Simplified Governance:Sensitive user data doesn’t need to leave the browser, meaning no external API calls are made to third-party servers for the AI processing itself, which is a huge plus for privacy and can simplify data governance including Google Workspace Marketplace verification and Add-on data privacy policies.
  • Potential for Cost-Free GenAI (with caveats!): Client-side processing can reduce or eliminate server-side AI costs for certain tasks. Remember, “Nano” is smaller than its cloud counterparts, so it’s best for well-scoped features. This smaller size means developers should think carefully about their implementation, particularly around prompt design to achieve the desired accuracy, as the model’s capacity for understanding extremely broad or complex instructions without guidance will differ from larger models.
  • Improved User Experience & Offline Access:Expect faster interactions due to minimise network latency.

The biggest takeaway here is the opportunity to explore new avenues for GenAI capabilities in your Add-ons, albeit with the understanding that this is experimental territory and on-device models have different characteristics and capacities compared to larger, cloud-based models.

Proof of Concept: AI-Powered Text-to-Diagram Add-on

To showcase the tangible possibilities of on-device text processing, the demonstrator Add-on (available in the Nano-Prompt-AI-Demo GitHub repository) focuses on a text-to-diagram use case:

  • Users can describe a diagram in natural language (e.g., “flowchart for a login process”).
  • The Add-on then uses the Gemini Nano API via the Prompt API to convert this text description into MermaidJS diagram code.
  • It also allows users to directly edit the generated MermaidJS code, see a live preview, and utilise an AI-powered “Fix Diagram” feature if the code has errors.
  • Finally, the generated diagram can be inserted as a PNG image into their Google Workspace file.

Nano Prompt API Demo

This example illustrates how the Prompt API can be used for practical tasks within a Google Workspace environment.

Under the Bonnet: Utilising the Chrome Gemini Nano Prompt API for Text

The Add-on interacts with Gemini Nano via client-side JavaScript using the LanguageModel object in the Sidebar.html file. I should also highlight that all of the Sidebar.html code was written by the Gemini 2.5 Pro model in gemini.google.com, with my guidance which included providing the appropriate developer documentation and this explainer for the Prompt API.

The Add-on’s core logic for text-to-diagram generation includes:

  • Session Creation and Prompt Design for Gemini Nano:A LanguageModel session is created using LanguageModel.create().
  • Generating Diagrams from Text: The user’s natural language description is sent to the AI via session.prompt(textDescription).
  • AI-Powered Code Fixing: If the generated or manually entered MermaidJS code has errors, the faulty code along with the error message is sent back to the model for attempted correction.

Given that Gemini Nano is, as its name suggests, a smaller LLM, careful prompt design is key to achieving optimal results. In this demonstrator Add-on, for instance, the initialPrompts (system prompt) play a crucial role. It not only instructs the AI to act as a MermaidJS expert and to output onlyraw MermaidJS markdown, but it also includes two explicit examples of MermaidJS code within those instructions.

Providing such “few-shot” examples within the system prompt was found to significantly improve the reliability and accuracy of the generated diagram code from text descriptions. This technique helps guide the smaller model effectively.

Navigating Experimental Waters: Important Considerations (and Reassurances)

It’s important to reiterate that the majority of AI APIs are still experimental. Functionality can change, and specific Chrome versions and flags are often required. I recommend referring to official Chrome AI Documentation and Joining the Early Preview Program for the latest details and updates.

Before you go updating your popular production Google Workspace Add-ons developers should be aware of the current system prerequisites. As of this writing, these include:

  • Operating System: Windows 10 or 11; macOS 13+ (Ventura and onwards); or Linux.
  • Storage: At least 22 GB of free space on the volume that contains your Chrome profile is necessary for the model download.
  • GPU: A dedicated GPU with strictly more than 4 GB of VRAM is often a requirement for performant on-device model execution.

Currently, APIs backed by Gemini Nano do not yet support Chrome for Android, iOS, or ChromeOS. For Workspace Add-on developers, the lack of ChromeOS support is a significant consideration.

However, Google announced at I/O 2025 in the ‘Practical built-in AI with Gemini Nano in Chrome’ session that the text-only Prompt API, powered by Gemini Nano, is generally available for Chrome Extensions starting in Chrome 138. While general web page use of the Prompt API remains experimental this move hopefully signals a clear trajectory from experiment to production-ready capabilities.

Bridging the Gap: The Hybrid SDK

To address device compatibility across the ecosystem, Google has announced a Hybrid SDK. This upcoming extension to the Firebase Web SDK aims to use built-in APIs locally when available and fall back to server-side Gemini otherwise, with a developer preview planned (see https://goo.gle/hybrid-sdk-developer-preview for more information). This initiative should provide a more consistent development experience and wider reach for AI-powered features.

A Glimpse into the Future: Empowering Workspace Innovation

On-device AI opens new opportunities for privacy-centric, responsive, and cost-effective Add-on features. While the demonstrator Add-on focuses on text generation, the Prompt API and the broader suite of on-device AI tools in Chrome offer much more for developers to explore

Focusing on Unique Value for Workspace Add-ons

It’s important for developers to consider how these on-device AI capabilities—be it advanced text processing or new multimodal interactions which support audio and image inputs from Chrome 138 Canary—can be used to extend and enhance user experience in novel ways, rather than replicating core Gemini for Google Workspace features. The power lies in creating unique, value-added functionalities that complement native Workspace features.

Explore, Experiment, and Provide Feedback!

This journey into on-device AI is a collaborative one and Google Workspace developers have an opportunity to help shape on-device AI.

  1. Explore the Demo: Dive into the Nano-Prompt-AI-Demo GitHub repository to see the text-to-diagram features in action.
  2. Try It Out: Follow setup instructions to experience on-device AI with the demo, and consider exploring multimodal capabilities for your own projects by referring to the latest Early Preview Program updates.
  3. Provide Feedback: Share your experiences either about the example add-on or through the Early Preview Program.

I hope you have as much fun working with these APIs as I have and look forward to hearing how you get on. Happy Scripting!

Agent2Agent (A2A) Communication in Google Workspace with Apps Script

 

Exploring Agent2Agent (A2A) protocol implementation in Google Apps Script seamlessly allows AI agents to access Google Workspace data and functions. This could enable complex workflows and automation, overcoming platform silos for integrated AI applications.

The buzz around AI and collaborative agent systems is growing, and with it, the need for standardized communication. The recently introduced Agent2Agent (A2A) protocol aims to enable exactly that – allowing different AI agents, regardless of their underlying framework, to discover each other’s capabilities and work together. But how can the Google Workspace developer community tap into this exciting new frontier?

Enter prolific Apps Script contributor Kanshi Tanaike, who has once again provided a valuable resource for the community. Kanshi has published a detailed guide and a Google Apps Script library demonstrating how to build an Agent2Agent (A2A) server using Google Apps Script.

Why is this significant?

Kanshi’s work explores the feasibility of implementing a core A2A server component directly within the Google Workspace ecosystem. As Kanshi notes, “Such an implementation could seamlessly allow AI agents to securely access and utilize data and functionalities across Google services like Docs, Sheets, and Gmail via a standardized protocol.”. This opens up possibilities for:

  • Integrating AI agents with your Google Workspace data: Imagine AI agents that can directly interact with your Sheets, Docs, Drive files, or Gmail.
  • Building sophisticated AI-powered workflows: Automate complex tasks that span across different services, orchestrated by communicating AI agents.

Kanshi’s guide walks through the setup and implementing functions that allow AI agents to interact with Google Workspace services like Drive or external APIs via UrlFetchApp. This work significantly lowers the barrier to entry for Google Workspace developers looking to experiment with and implement A2A-compatible agents and as such I highly encourage you to check out the linked source post for the complete guide, code, and library details.

Source: Building Agent2Agent (A2A) Server with Google Apps Script

Automate Your Organisational Chart with Apps Script & Google Sheets

In this guide, I’ll show you how to build a data-driven organizational chart based on Google Sheets data, using Apps Script and the OrgChart JavaScript library.

Recently, I used Gemini Deep Reacher to “find the most popular or useful Google Apps Script tutorials?”. There was no mention of AppsScriptPulse (rude, but if you are curious, here is the report :), but it did introduce me to the work of Joseph Petty on the GreenFlux Blog.

One tutorial, in particular, stood out for its practical application for many organisations: “Building A Data-Driven Organisational Chart In Apps Script”.

Creating diagrams, particularly organisational charts, often requires laborious design work and manual revisions. Petty’s tutorial directly addresses this common frustration by demonstrating how Google Sheets, Apps Script, and the OrgChart JavaScript library can produce dynamic, data-driven organisational charts that automatically stay current.

The Core Idea: From Spreadsheet Data to Visual Chart

The beauty of this approach lies in its simplicity and efficiency. Most organisations already maintain employee data, including supervisor information, in spreadsheets or databases. Petty’s method cleverly taps into this existing data source.

The tutorial guides you through several key steps:

  • Foundation Setup: Deploy a basic Apps Script web app, creating an index.html for the frontend and Code.gs for server-side logic (including a doGet() function).
  • OrgChart Library Integration: Introduce the open-source OrgChart JavaScript library, which uses a nested JSON structure to define the visual hierarchy.
  • Data Transformation: Write an Apps Script function (getEmployeeData) to pull data from Google Sheets (employee IDs, names, titles, supervisor IDs) and convert it into the required nested JSON format for the chart.
  • Dynamic Connection: Pass the generated JSON data from Code.gs to the OrgChart library in index.html using google.script.run.withSuccessHandler() to render the chart.

The Result? An Always Up-to-Date Org Chart

By following these steps, you can create an organisational chart that’s directly linked to your Google Sheet. When an employee changes roles, or a new team member joins, simply update the spreadsheet, and your web app will reflect these changes automatically. No more manual graphic updates!

For the complete code and detailed setup instructions, please follow the link to the original tutorial on GreenFlux Blog.

[Update 2025-05-16: A great tip from Pablo Felip Monferrer: “might be worth mentioning that the good old Sheets has a native organizational chart that can be easily published, too (hint: employee names in a third column can be displayed as tooltips)”.

Image credit: Pablo Felip Monferrer

Source: Building A Data-Driven Organizational Chart In Apps Script

Keys to Success: Amit Agarwal on Developing Google Workspace Add-ons, an Interview with Chanel Greco

Amit is a Google Workspace developer, the founder of Digital Inspiration, and a Google Developer Expert. He has published multiple Google Workspace Add-ons to the Workspace Marketplace and they have a combined 46 million+ installs.

Looking to create successful Google Workspace Add-ons? Chanel Greco (Google Workspace DevRel) recently interviewed Amit Agarwal (Founder, Digital Inspiration), who shared valuable insights for aspiring developers.

Amit Agarwal highlighted several critical areas for add-on development success:

  • Solve Real Problems with Great UX: Focus on addressing specific user needs with a clean, intuitive interface. A compelling first-run experience is key.
  • Build Trust with Documentation: Provide clear, comprehensive documentation and tutorials. A detailed privacy policy is crucial for user trust and smoother Google reviews. Prompt communication with Google during review is also important.
  • Smart Business & Future Focus: A freemium model can drive adoption. Keep an eye on future trends like AI integration to enhance your add-on.
  • Engage the Community: Participate in the Google Developer Community and programs like Google Developer Experts to learn and grow.

To find out more about these areas and more, check out the full interview.

Source: Developer Spotlight with Amit Agarwal, Founder Digital Inspiration

Simplify Google Sheets Table Management with New API Support

Following the improvements made to tables in Google Sheets in March and April, we’re excited to introduce API support for tables. Now, users will be able to take basic actions to create and modify tables via the Sheets API.

Following enhancements to Google Sheets tables last year, Google recently highlighted an update for developers: the Sheets API now supports tables. This is great news for the Google Workspace developer community, as it allows for direct programmatic creation and modification of tables, moving beyond previous reliance on workarounds.

For a while, developers have found clever ways to interact with table-like structures, such as Kanshi Tanaike’s notable 2024 solution using a mix of Apps Script and Sheet formulas. While these methods were very clever, the new, direct API support offers a more robust and straightforward way for interacting with tables in Google Sheets. For Google Apps Script users, for now this will require using the Google Sheets Advanced Service to call these new table methods, as direct integration into the SpreadsheetApp service hasn’t been announced at this time.

Key API Capabilities for Tables:

The Sheets API now lets developers:

  • Add Tables: Create tables with defined names, ranges, and specific column properties (like ‘PERCENT‘ or ‘DROPDOWN‘ with validation).
  • Update Tables: Modify table size (add/remove rows/columns), and toggle table footers. The API also provides methods like InsertRangeRequest and DeleteRangeRequest for more granular control.
  • Append Values: Easily add new rows to the end of a table using AppendCellsRequest, which intelligently handles existing data and footers.
  • Delete Tables: Remove entire tables and their content (DeleteTableRequest) or just the formatting while retaining data (DeleteBandingRequest).
  • Utilise Column Types: Work with various column types including numeric, date, dropdown, smart chip, and checkbox.

For further details, the official Google Workspace Updates blog and the Sheets API developer documentation on tables are your best resources.

Enhanced Text Replacement with Styling in Google Slides using Google Apps Script

This is a sample Google Apps Script designed to replace all instances of specific text within a Google Slides presentation, while simultaneously applying a desired text style. The built-in Presentation.replaceAllText() method within the Google Slides service is limited; it efficiently replaces text strings but lacks the functionality to modify text formatting during the replacement process. This limitation poses a challenge when aiming for styled text replacements. This report presents a detailed script solution that overcomes this constraint.

Have you ever needed to replace text across your Google Slides presentation but also wanted to apply specific formatting to the new text at the same time? The standard replaceAllText() method in Apps Script is handy for bulk text replacement, but it falls short when you need to control the styling – like font, size, or colour – during the replacement process.

Community contributor Kanshi Tanaike has developed a clever solution to overcome this limitation. Tanaike has shared a Google Apps Script function that not only finds and replaces text throughout all elements in your slides (including shapes, tables, and grouped objects) but also applies your desired text styles simultaneously.

The script works by iterating through the elements on each slide. When it finds the text you want to replace, it uses TextRange methods to perform the replacement and apply the specified formatting attributes, such as font family, size, colour, bold, italics, underline, and more.

This approach provides significantly more control than the built-in method, allowing you to ensure that automatically replaced text matches the exact styling you need for visually consistent and polished presentations. Tanaike’s post includes the full script, configuration details for specifying the text and styles, and sample slides showing the results.

Source: Enhanced Text Manipulation in Google Slides using Google Apps Script

Google Cloud Next ’25 Developer Spotlight: Diving Deep into Flow, AI & the Future of Workspace Automation

I was thrilled to be invited by Chanel Greco (Google Workspace Developer Advocate) to join Vinay Vyas (Software Engineer, Google) and Steve Bazyl (Developer Program Engineer, Google) for a Developer Spotlight session recorded at Google Cloud Next ‘25.

We explored the exciting evolution of Google Workspace development, focusing on the tools and technologies shaping the future of automation and AI integration.

What We Covered:

  • The Rise of Flows for Workspace Automation: We kicked things off discussing the potential of Flows, a powerful new tool Google had just announced which is designed to simplify task automation in Google Workspace. We explored how developers can tap into its potential by building custom actions, including integrating with Vertex AI [01:17].
  • Extending Capabilities with Apps Script: Your existing Apps Script skills remain crucial! We discussed how they empower developers to extend Flows capabilities as the product evolves [02:08], offering significant opportunities within this user-centric automation tool [01:52].
  • Workspace as an Integrated Platform: Learn about the ongoing efforts to enhance connectivity with third-party services [02:35] and how add-ons (including Chat apps deployed as add-ons [03:32]) are key to keeping users productive within the Workspace context [02:52].
  • The Gemini Effect on Development: Hear our experiences with Gemini 2.5 and its significant impact on code development, particularly for Apps Script [05:29]. We discuss its impressive ability to generate substantial, high-quality code for complex tasks [06:35].
  • AI Agents & The Future: We explored the concept of AI Agents powered by Gemini within Google Apps Script for automating tasks using natural language and discussed the exciting prospects for deeper Gemini integration directly within Apps Script [14:41]. I checky asked Steve if there was going to be a Gemini Advanced Service for Apps Script (you’ll have to watch the video to find out the answer :).

Why Watch?

If you are interested in understanding the future direction of Google Workspace development, this discussion hopefully provides some practical perspectives and explores exciting possibilities.

Source: Developer Spotlight – Google Cloud Next 2025 Special Edition

AppSheet Gains Gemini Smarts: Native AI Tasks Simplify Automation (No Apps Script Needed!)

Image credit: Google

We’re thrilled to announce that Gemini in AppSheet Solutions is now available in Public Preview for Enterprise users! As announced during the AppSheet breakout session at Google Cloud Next 2025 just a few weeks ago, this powerful new capability allows AppSheet Enterprise Plus users to integrate Google’s Gemini models directly into their automation workflows.

Google recently announced some exciting developments for AppSheet, with the news that creators can now directly integrate Gemini AI capabilities into your AppSheet apps. While developers have previously found ways to connect AppSheet to Gemini including using Google Apps Script (like the invoice processing example using the GeminiApp library previously discussed on Pulse), this new update promises to make AI-powered automation accessible to everyone, no coding required.

What This Means for AppSheet Creators

This move significantly lowers the barrier for integrating AI into AppSheet workflows. Instead of setting up API keys, writing Apps Script functions, and managing libraries like GeminiApp to call the Gemini API for tasks like data extraction, creators can now use a native AI Task step within AppSheet automations.

As highlighted in Google’s announcement, this new approach offers several advantages:

  • Simplified AI Integration: The native AI Task aims to handle jobs like extracting specific data from uploaded photos or PDFs and categorising text – directly within AppSheet. This replaces the need for external scripts for many common AI tasks.
  • Build with Confidence: The GA AI Task Step Testing feature allows creators to test and refine AI prompts and configurations directly in the editor using sample data before deployment, a crucial step for reliable AI.
  • No-Code Accessibility: By embedding Gemini capabilities directly, AppSheet makes powerful AI accessible to creators who may not have coding expertise.
  • Controlled Deployment & Oversight: Admins still control feature access, and workflows can still incorporate human review steps alongside the AI Task.

Potential Use Cases

Google suggests the AI task can be used for:

  • Information Extraction: Getting details from images (serial numbers, meter readings) or documents (PO numbers, tracking info, report details).
  • Record Categorisation: Classifying expenses, maintenance requests, or customer feedback automatically.

These are similar goals to what was achievable via Apps Script previously, but now potentially much simpler to implement directly in AppSheet.

A Big Step for No-Code AI

This native integration represents a significant simplification compared to earlier methods requiring Apps Script. By embedding Gemini directly into AppSheet automations, Google is making advanced AI capabilities much more accessible for business users of all levels.

For full details and setup instructions, refer to the official Google announcement and linked resources.

Source: Gemini in AppSheet now in Public Preview for Enterprise users! (And AI task testing is GA!)

Streamlining Google Workspace Development: Editing JSON files in Google Drive with Apps Script (and a little help from AI)

Storing JSON files in Google Drive offers a practical approach for Google Workspace developers, especially when combined with Google Apps Script. While Drive lacks a built-in JSON editor, AI tools like Gemini can rapidly prototype solutions, such as web-based editors. However, creating a robust application requires more than just a quick fix. It involves understanding syntax highlighting, managing dependencies, and navigating the constraints of the Apps Script platform, highlighting the importance of both rapid prototyping and robust engineering skills.

I recently explored how to effectively manage JSON configuration files within Google Drive using Google Apps Script, and the journey from quick AI-assisted prototypes to robust solutions.

As part of this I delve into the benefits of storing JSON in Drive, the challenges of editing, and how AI tools like Gemini can provide a great starting point. However, as I discovered, building a truly polished tool requires deeper technical knowledge and problem-solving.

Check out the article for insights on navigating the development process and, if you want one, an Apps Script powered JSON Editor for Google Drive.

Source: Streamlining Google Workspace Development: Editing JSON files in Google Drive with Apps Script (and a little help from AI)

Programmatically Iterating on Images with Imagen 3, Vertex AI, and Apps Script

Use Gemini and Imagen 3 on Vertex AI to create the images you envision. Generate tailored images from reference sources with Apps Script.

Have you ever generated an image using Gemini in Google Workspace and wished you could easily tweak or iterate on it? While Gemini for Workspace is great for initial creation, iterating on those images directly isn’t currently straightforward. A recent post by Stéphane Giron highlights a programmatic approach using Google Apps Script, Vertex AI (with Imagen 3 and Gemini models) to achieve the goal of generating image variations based on a source image.

Stéphane’s method uses a source image (which could be one previously generated or found elsewhere) which is provided to the Vertex AI API for Gemini (e.g., gemini-2.0-pro) along with text instructions for the required changes. The Gemini model analyzes the image and the request to generate a new prompt. This new prompt is then used with the Imagen 3 model (e.g., imagen-3.0-generate-001) via Vertex AI to generate the final image variation.

It’s interesting to contrast this with another solution we’ve previously featured from Kanshi Tanaike on ‘Iterative Image Generation with the Gemini API and Google Apps Script‘. While Tanaike’s method uses the Gemini API’s chat history to iteratively build an image from sequential text prompts, Stéphane’s focuses on reinterpreting a source image with specific modifications via a newly generated prompt.

You can check out Stéphane Giron’s source post for the complete code and setup instructions.

Source: Similar Image Generation with Imagen 3 on Vertex AI with Google Apps Script