tanaike - Google Apps Script, Gemini API, and Developer Tips

The Thinker

Allowing Access by IMPORTHTML, IMPORTDATA, IMPORTFEED, IMPORTXML, and IMPORTRANGE on Google Spreadsheet with Google Apps Script

Gists

Updated on April 26

From this X and this blog, it seems that in the current stage, this situation can be resolved using Sheets API. The sample script of Google Apps Script is as follows. Before you test this, please enable Sheets API at Advanced Google services.

function myFunction() {
  // Please set your Spreadsheet ID.
  const spreadsheetId = "###";
  
  const requests = [{
    updateSpreadsheetProperties: {
      properties: { importFunctionsExternalUrlAccessAllowed: true },
      fields: "importFunctionsExternalUrlAccessAllowed"
    }
  }];
  Sheets.Spreadsheets.batchUpdate({ requests }, spreadsheetId);
}

As additional information, in this case, when importFunctionsExternalUrlAccessAllowed: true is modified to importFunctionsExternalUrlAccessAllowed: false, an error like Cannot set import functions external URL access allowed from true to false. occurs. It seems that when access is allowed once, this cannot be canceled.

Creating Image Bot using Gemini with Google Apps Script

Gists

Abstract

New Gemini API opens doors for developers to integrate its AI power into apps, potentially impacting education, healthcare, and business. The latest Gemini 1.5 brings even more features. This report showcases an image bot using Gemini as one example of its diverse applications. Showcasing its diverse application potential across various fields.

Introduction

The recent release of Gemini as an accessible API on Vertex AI and Google AI Studio empowers developers to integrate its vast capabilities into their applications, potentially revolutionizing fields like education, healthcare, and business. Adding even more powerful features with the recently announced Gemini 1.5, this tool promises even greater impact. Ref and Ref I believe Gemini significantly expands the potential for diverse applications across various fields. To showcase its potential, this report introduces an image bot using Gemini with Google Apps Script and Google Drive. This is just one example of the many compelling use cases developers can build with Gemini.

Guide to Function Calling with Gemini and Google Apps Script

Gists

Abstract

Powerful AI tool Gemini’s API release (Vertex AI & Google AI Studio) opens doors for diverse applications. Its recent upgrade to version 1.5 boosts capabilities. This report demonstrates using simple Google Apps Script function calls to leverage Gemini’s power for both data retrieval and content generation.

Introduction

The recent release of the LLM model Gemini as an API on Vertex AI and Google AI Studio unlocks a world of possibilities. Ref Excitingly, Gemini 1.5 was just announced, further expanding its capabilities. Ref I believe Gemini significantly expands the potential in various situations and paves the way for diverse applications. Notably, the Gemini API can retrieve new data and generate content through function calls. In this report, I introduce the basic flow of function calling in the Gemini API using a simple Google Apps Script.

Applying Gemini Pro API to Flexible Templates using Google Apps Script

Gists

Abstract

New “semantic search” features in Gemini API help find desired information within its corpora. While using these features with Google Apps Script was complex, a new library simplifies the process. This report proposes using this library with Gemini-generated content to automate template processes in Google Docs and Slides, creating a more flexible workflow.

Introduction

The semantic search opens up a new wind for finding the expected values. Recently, the APIs for managing corpora have been added to Gemini API. Ref When the corpora of Gemini API is used, the semantic search can be effectively achieved. Ref However, when the corpora are tried to be used with Google Apps Script, the script is complicated cumbersome. To address this challenge, I have created a library for managing the corpora using Google Apps Script. Ref With this library, managing corpora becomes effortless, requiring only straightforward scripts.

Convert Contact URL to Resource Name for People API using Google Apps Script

Gists

This is a sample script for converting a contact URL of “person/c###” to a resource name “people/c###” for People API using Google Apps Script.

When you open each contact at Contacts with your browser, you can see the URL like https://contacts.google.com/person/c###################.

Here, you might have a situation where you are required to retrieve the resource name for People API from this URL. But, in the current stage, person/c################### cannot be directly used as the resource name people/c###################. In this report, I would like to introduce a sample script for converting from person/c################### to people/c###################.