AppsScriptPulse

Automatically creating descriptions of files in Google Drive using Gemini Pro API and Google Apps Script

Gemini LLM, now a Vertex AI/Studio API, unlocks easy document summarization and image analysis via Google Apps Script. This report details an example script for automatically creating the description of the files on Google Drive and highlights seamless integration options with API keys.

In this blog post, Kanshi Tanaike shows how you can automatically create descriptions for files on Google Drive using the Gemini Pro API with Google Apps Script. The post includes a step-by-step guide on how to set up and use the Gemini Pro API by generating a key is Google AI Studio (formerly Maker Suite). There are geographic restrictions on Google AI Studio, but you can call Gemini Pro from a Google Cloud project with a little more setup (a previous post sharing Tutorial: Respond to incidents with Google Chat, Vertex AI, and Apps Script outlines a general approach for connecting Apps Script to Google Vertex AI services.)

The post includes a couple of examples showing how Gemini can be used to provide responses to both text and visual prompts. Gemini Pro is still in public preview and as Kanshi Tanaike highlights rate limiting will likely prevent putting these solutions into production just now. At this point hopefully there is enough to start experimenting with Google Workspace integrations to Gemini.

Source: Automatically Creating Descriptions of Files on Google Drive using Gemini Pro API with Google Apps Script

GenAI for Google Workspace: Exploring the PaLM 2 API and LLM capabilities in Google Sheets — Part 2

Imagen: An photo image which has a laptop with a spreadsheet application which appears to have rays of light

This is the second part exploring the GenAI capabilities in Google Sheets. In this part learn how you can make an Enhanced Smart Fill for Google Sheets

Google recently announced the latest feature for Duet AI for Google Workspace with Enhanced Smart Fill, which uses GenAI in Google Sheets to generate content based on data and the patterns entered by the user.

Continuing a previous post exploring the PaLM 2 API and LLM capabilities in Google Sheets, this post looks provides a Google Sheet template for experimenting with LLM prompts and spreadsheet data, including how you could make a ‘Enhanced Smart Fill’-like star review generator.

The post includes everything you need to get started, with you only having to make your own MakerSuite API key.

Source: GenAI for Google Workspace: Exploring the PaLM 2 API and LLM capabilities in Google Sheets — Part 2

Tutorial: Respond to incidents with Google Chat, Vertex AI, and Apps Script

Imagen: photo looking over the shoulder of a robot looking at a screen with chat messages and hand writing notes

This tutorial shows how to make a Google Chat app that responds to incidents in real time. When responding to an incident, the app creates and populates a Chat space, facilitates incident resolution with messages, slash commands, and dialogs, and uses AI to summarize the incident response in a Google Docs document.

Paraphrasing noted Google Workspace Developer Expert, Romain Vialard, GenAI has made Google Chat apps a tangible prospect. This tutorial from the  Google Developers site is a great example of how you can use Google’s Vertex AI with Google Chat. The tutorial will help you create a Google Apps Script powered Chat app that is able to summaries the messages in a Google Chat space.

There is a lot to take away from this example, but here are some of the headlines:

  • Setting a Google Cloud Project to use the new Google Chat Advanced Service for Apps Script
  • Setup and code for making calls to Google’s Vertex AI PaLM API (LLM) from Google Apps Script
  • Using the responses from Vertex AI to generate new assets.

There is a lot more you can do from this starting point, but hopefully it gives you a great starting point.

Source: Respond to incidents with Google Chat, Vertex AI, and Apps Script  |  Google for Developers

How to built a Support AI Assistant for Google Workspace with Apps Script, Gen AI and Google Chat

Building a Support AI Assistant for Google Workspace using Apps Script, Gen AI, and Google Chat.

This post from Stéphane Giron highlights one approach for improving responses from LLMs by integrating Google Custom Search Engine responses into the prompt. In this example Stéphane used Google Apps Script to power the AI Assistant, integrating with Google Chat for the user interface and Cloud Functions to reformat data.

This post is another example of the ‘power of the prompt’ and how LLM prompting strategies are a very effective way to utilise LLMs without having to ground or fine tune. If you are interested in understanding more here is a useful notebook produced by Michael W. Sherman which illustrates two powerful LLM prompting strategies: Chain of Thought and ReAct (Reasoning + Acting).

Source: How we built our Support AI Assistant for Google Workspace with Apps Script, Gen AI and Google Chat

Introducing ChatGPTApp, a new library for Google Apps Script and ChatGPT (and a new way to generate personalised mail merges)

Last month, OpenAI announced Function calling, “a new way to more reliably connect GPT’s capabilities with external tools and APIs”. Super useful ❤️ and we decided to integrate that with Google Apps Script.

Following on from yesterday’s Pulse post which highlighted Ben Collins reflections on ‘What can AI do for you as a Google Sheets user? Is the hype justified?’, here is a contribution from another Apps Script expert, Romain Vialard, announcing a ChatGPT library for Google Apps Script.

The source post highlights a number of examples, including the standard ‘prompt’ calling. Where this post gets very interesting is integration with Open AI’s function calling features:

In an API call, you can describe functions to gpt-3.5-turbo-0613 and gpt-4-0613, and have the model intelligently choose to output a JSON object containing arguments to call those functions. The Chat Completions API does not call the function; instead, the model generates JSON that you can use to call the function in your code.

To illustrate this below is a screenshot of a very slightly extended example, which has a Google Sheet with the headings email, name and tip topic. The functions are described to ChatGPT and in the case of sendMessage() the parameters it requires. The ChatGPTApp library handles the functions and in the case of the getContactsList() uses it to pass the Google Sheet data for ChatGPT to format a JSON response to correctly call the sendMessage() function.

I found it took me a while to start understanding what is going on and would recommend experimenting with the library and sample code to get a sense what is possible.

Source: Introducing ChatGPTApp, a new library for Google Apps Script

Automatic meeting minutes with Google Gen AI in Google Workspace (new opportunities with LLMs)

Who takes the notes ? Simple question we always ask at the begining of the meeting, maybe it will be over in a near future with Generative AI. Using Meet recording, included in the Google Workspace licences, we can generate the transcript of the meeting with Google Speech to Text API and then generate the minutes.

Lots of chatter around ‘Gen AI’, but cutting through the hype and, in particular, the Platform-As-A-Service opportunities created with generally available Large Language Models (LLM) opens lots of new doors for Workspace Developers.

This example from fellow Google Developer Expert, Stéphane Giron, is an area I think has the most potential, using LLMs in Google Workspace Add-ons such as Gmail, Docs, Calendar etc. With Google’s Vertex AI LLMs there is really opportunity to create powerful solutions whilst preserving data sovereignty. Exciting times!

Source: Automatic meeting minutes with Google Gen AI in Google Workspace

Master Google Apps Script UIs — Part 9: Elevating Your Game with TypeScript 👾

Taking JavaScript to the Next Level with TypeScript for your Google Apps Script Projects

A Warm Welcome Back to the Series 🎉

Hey there, and welcome back to our hands-on series on mastering Google Apps Script UIs! Now, if you’re serious about JavaScript, it’s high time we chat about TypeScript. TypeScript is a superset of JavaScript that brings static typing to the game. It’s like JavaScript put on its best suit and turned into a more organized, reliable version of itself. 😎

The reason a lot of developers are switching to TypeScript is because it can catch errors at compile-time, making debugging less of a headache (it’s like having a personal assistant who checks your work for mistakes so you don’t look silly later). In this part, we’ll let the Emojibar project rest (it’s earned it, after all!), and we’ll switch over to a different repository I frequently use as a boilerplate for my projects. This boilerplate is a work in progress, so don’t be surprised if it changes faster than you change your socks. 😅

Source: Master Google Apps Script UIs — Part 9: Elevating Your Game with TypeScript 👾

Master Google Apps Script UIs — Part 7: Routing in Your GAS Front-End

Introduction

Hey there, code wranglers! 🤠 Welcome back to our Google Apps Script (GAS) UI series. Today, we’re venturing into the wild world of Single Page Applications (SPAs). For the uninitiated, a SPA is a web application that interacts with the user dynamically, rewriting the current web page with new data from the web server, instead of the default method of the browser loading entire new pages.📚

Now, why are SPAs a big deal? They help in reducing the time taken to load the entire page because only a part of the page gets updated. We’re going to bring this SPA magic to our sidebar with the help of a slick Navigo router. 🎩

No worries if ‘Navigo’ sounds like a hip new dance move. By now, you should be pretty comfy with installing dependencies from NPM. But if not, it’s like adding a shiny new tool to your utility belt. It just gives you the superpowers you need to build your web app.

Source Master Google Apps Script UIs — Part 7: Routing in Your GAS Front-End

Copy macros to other Google Sheets (and how to centrally create/update Apps Script code to Google Workspace editors)

 

Image credit: Google

Manually copying Google Sheets macros from one spreadsheet to another can be time consuming and error-prone. This Google Workspace Add-on automatically copies a script project and attaches it to a user-specified spreadsheet. Though this solution focuses on Sheets macros, you can use it to copy and share any container-bound script.

Are you looking for a way to centralize your codebase but deploy it to container-bound scripts? Here is a tutorial for you from the Apps Script samples on the Google Developers site, highlighted by Steve Webster, which gives an alternative approach to deploying as an add-on or sharing a container-bound template.

In the tutorial, you’ll find code that uses the Apps Script API to perform functions like getting, creating, and updating container-bound scripts. As part of the solution you’ll see how you can get the source project content using the Apps Script API, then opening a target Google Sheet to either create or update the container script.

This solution is not limited to Google Sheets only. You can use the same process to update code in other Google Workspace editors like Docs, Forms, and Slides. Usually, I would recommend maintaining and distributing your code as an add-on, however, in certain scenarios, this alternative approach could work well.

Source: Copy macros to other spreadsheets  |  Apps Script  |  Google for Developers

Master Google Apps Script UIs — Part 6: Acing Client-to-Server Chatter with Promises 🤝

Welcome Back to Mastering Google Apps Script UIs: Client-to-Server Communication Spotlight

Oh, howdy folks! Just like a boomerang, you’ve found your way back to our marvelous series. If you thought the previous episodes were fire, wait till you see what’s cooking today! 🔥

We’re diving headfirst into the world of client-to-server communication. It’s like passing notes in class, but with a lot less paper and a lot more code. 📝➡️💻

Here’s the catch though — we can’t install Google Apps Script locally to run things on our dev server. Yep, that’s right. It’s like trying to install a toaster in a bathtub; it just ain’t happening. 🛁🚫🍞

But fear not, dear coder, for I’ve got a trick or two up my sleeve. We’re gonna finesse our way around this with some snazzy hacks like promises, polyfills, and mocks. Oh my!

Source: Master Google Apps Script UIs — Part 6: Acing Client-to-Server Chatter with Promises 🤝