⚙️ Installation — Metric Book Transcriber Add-On

This add-on runs in Google Docs™ and uses the Google™ AI (Gemini™) API to transcribe metric book images. Choose one of the installation options below. The API key can be entered the first time you run Transcribe Image (the add-on will prompt you), or set manually in Script properties.

🗺️ Choose your installation path

flowchart LR
  Start([Start]) --> Choose{Which option?}
  Choose -->|End user<br/>Easiest| O0["Option 0<br/>Marketplace"]
  Choose -->|Standalone script<br/>Test in any doc| O1[Option 1<br/>Test deployment]
  Choose -->|One document only| O2[Option 2<br/>Container-bound]
  Choose -->|clasp / repo sync| O3[Option 3<br/>Deploy from repo]
  O0 --> Key0["Set API key<br/>(prompted on first Transcribe)"]
  O1 --> Key1["Set API key<br/>(in-app or Script properties)"]
  O2 --> Key2["Set API key<br/>(in-app or Script properties)"]
  O3 --> Key3["Set API key<br/>(in-app or Script properties)"]
  Key0 --> Done([Use add-on])
  Key1 --> Done
  Key2 --> Done
  Key3 --> Done
Path Best for
Option 0 Recommended. Install from the Google Workspace™ Marketplace — one click, works in any Google Docs™ document.
Option 1 Standalone Apps Script project; run in any doc via Test deployments (Editor add-on).
Option 2 One Google Doc; script lives inside that document (Extensions → Apps Script).
Option 3 Using clasp or copying from repo; then follow Option 1 or 2 depending on project type.

✅ Prerequisites


This is the easiest option for end users. No code, no setup — just install and go.

flowchart LR
  A["🏪 Open Marketplace listing"] --> B[📥 Install]
  B --> C[📄 Open any Google Doc]
  C --> D["🔑 Set API key<br/>(prompted on first Transcribe)"]
  D --> E([✅ Ready])
  1. 🏪 Open the Metric Book Transcriber listing on the Google Workspace Marketplace (search for “Metric Book Transcriber” or use the direct link once published).
  2. 📥 Click Install and grant the requested permissions.
  3. 📄 Open any Google Doc. You should see the menu ExtensionsMetric Book Transcriber with Transcribe Image, Import Book from Drive Folder, and Setup API key & model.
  4. 🔑 The first time you run Transcribe Image, the add-on prompts you to enter a Google AI (Gemini) API key and choose a model (default: Gemini Flash Latest, free tier ~20 requests/day). Get a free key, paste it, pick a model, and click Save & Continue. Your key and model are stored privately (per user). To change them later, use Setup API key & model. See rate limits for free tier and billing.

That’s it — you can now import images from Drive and transcribe them. See the User Guide for step-by-step usage.


1️⃣ Option 1: Add-on deployment (standalone project)

Use this option if your script lives in a standalone Apps Script project (e.g. created at script.google.com). You run it in the context of a document via Test deployments.

⚠️ Important: Test deployments must use the Editor add-on type and have a test document selected. Without this, the add-on menu will not appear in the document.

flowchart LR
  A[📂 Open standalone<br/>Apps Script project] --> B[📋 Check appsscript.json]
  B --> C[🚀 Deploy → Test deployments]
  C --> D[➕ Editor add-on<br/>+ Add test doc]
  D --> E[▶️ Execute test]
  E --> F[📄 Doc opens<br/>Authorize]
  F --> G["🔑 Set API key<br/>(prompted on first Transcribe<br/>or via Script properties)"]
  G --> H([✅ Ready])
  1. 📂 Open your standalone project in the Apps Script editor.
  2. 📋 Ensure appsscript.json matches the repo (no addOns block; includes script.container.ui scope). See addon/appsscript.json.
  3. 🚀 Create a test deployment:
  4. ▶️ Run the test: In the Test deployments dialog, select your saved test and click Execute. The test document opens with the add-on available.
  5. 📄 In the document you should see the Metric Book Transcriber menu (e.g. ExtensionsMetric Book TranscriberTranscribe Image, Import Book from Drive Folder, Setup API key & model). Authorize when prompted.
  6. 🔑 Set the API key and model. You have two options:

The add-on runs in the context of the test document. When you run Transcribe Image, a dialog shows “Awaiting response from Gemini API… This may take up to 1 minute.” To test with the latest code, keep Latest code in the test and refresh the document after saving changes.


2️⃣ Option 2: Add script to document (container-bound)

Use this option to attach the add-on directly to one document. The script is bound to that document.

flowchart LR
  A[📄 Open Google Doc] --> B[🔌 Extensions → Apps Script]
  B --> C[📝 Paste Code.gs, Prompt.gs<br/>Update appsscript.json]
  C --> D[💾 Save]
  D --> E[▶️ Run onOpen]
  E --> F[🔄 Reload document]
  F --> G["🔑 Set API key<br/>(prompted on first Transcribe<br/>or via Script properties)"]
  G --> H([✅ Menu appears])
  1. 📄 Open the Google Document you use for metric books (or create a new one).
  2. 🔌 ExtensionsApps Script. This opens the script editor bound to this document.
  3. 📝 Replace the default script with the add-on code:
  4. 💾 Save the project (Ctrl+S / Cmd+S).
  5. ▶️ Run onOpen once from the script editor (authorize if prompted). 🔄 Reload the document; the menu ExtensionsMetric Book Transcriber (Transcribe Image, Import Book from Drive Folder, Setup API key & model) should appear.
  6. 🔑 Set the API key: run Transcribe Image and the add-on will prompt you with instructions and a link to Google AI Studio. Alternatively, set it manually in Project SettingsScript properties (note: the in-app dialog stores the key per user; manual Script properties are shared).

3️⃣ Option 3: Deploy from repo (clasp or manual)

Use this option if you use clasp or want to keep the add-on in sync with this repository.

flowchart LR
  A[📥 Clone repo] --> B{How to deploy?}
  B -->|clasp| C[📦 npm install clasp<br/>clasp login]
  B -->|Manual| D[📋 Copy addon/* files]
  C --> E[🚀 clasp create / push<br/>--rootDir addon]
  E --> F["🔑 Set API key<br/>(prompted on first Transcribe<br/>or via Script properties)"]
  D --> F
  F --> G{Bound or standalone?}
  G -->|Bound to doc| H[▶️ onOpen + Reload]
  G -->|Standalone| I[Use Option 1<br/>Test deployment]
  H --> J([✅ Ready])
  I --> J
  1. 📥 Clone this repo and cd into it.
  2. With clasp:
  3. Without clasp: Copy the contents of addon/Code.gs, addon/Prompt.gs, and addon/appsscript.json into your Apps Script project (create one from a document via ExtensionsApps Script, or create a standalone at script.google.com).
  4. 🔑 Set the API key and model: run Transcribe Image and the add-on will prompt you (or use Setup API key & model), or set the key manually in Project SettingsScript properties (note: the in-app dialog stores the key and model per user; manual Script properties are shared).
  5. If the script is bound to a document, run onOpen once and reload the doc. If it is standalone, use Option 1 (Test deployments) to run it in a document.

The manifest (appsscript.json) includes an addOns block with a logoUrl pointing to the icon hosted in this repo. The logoUrl must be a public HTTPS URL (e.g. a GitHub raw URL or Cloud Storage). Required sizes for the Marketplace listing: 128×128 px and 32×32 px (square, color, transparent background). See addon/img/README.md for details.

🔑 API key and model

🔧 Troubleshooting

Issue What to do
Menu doesn’t appear Reload the document. For container-bound scripts, ensure the script is bound to this document (Extensions → Apps Script opens the same project). For test deployments, run Execute from Deploy → Test deployments.
“Please set your Google AI API key” / no key Run Transcribe Image — the add-on will prompt you to enter a key and choose a model, with a link to Google AI Studio. Or use Setup API key & model to set or change key and model.
“Authorisation is required to perform that action” You may be a collaborator on the doc (not the person who added the add-on). Install the add-on for your account: ExtensionsMetric Book Transcriber and complete the authorization when prompted. Or remove and re-add the add-on to re-authorize.
Quota exceeded / 429 Free tier has limited requests per day (e.g. ~20 for Gemini Flash Latest). The add-on shows the API error in the dialog. Check rate limits; consider enabling billing or switching model via Setup API key & model.
Cannot access folder (Import from Drive) Ensure the folder is shared with you or you own it. If using a custom GCP project (e.g. for Marketplace), enable the Google Drive API in that project: APIs & Services → Library → Google Drive API. Re-authorize the add-on if you changed permissions.
API errors / 403 Confirm the API key is valid and the Generative Language API is enabled. Check Google AI Studio or Cloud Console.
Timeout The script uses a 60-second timeout. Try a smaller image or try again.

For usage (document structure, Context section, step-by-step with screenshots), see USER_GUIDE.md.