AUDIO

Listen to this page

0:00
Chapters

    google_docs — agent writes into Google Docs & Sheets

    The agent can store data in the user's Google account(s) — e.g. "save this bill to my spreadsheet" (chat feeds receipts/photos/voice into docs/sheets). One plugin, one tool: google_docs with an action switch.

    Installation

    • Select the plugin in the installer, or enable it from the Plugins screen.

    • Create a Google Cloud project with Docs, Sheets and Drive APIs enabled; create OAuth consent credentials (type Web application; the consent screen stays in test mode by default and only lets in accounts the admin explicitly adds as test users).

    • Put GOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET into the Env variables screen.

    • Register the ONE shared redirect URI for ALL holai Google plugins:

      GET /api/v1/oauth/google/callback?state=<plugin>:<nonce>
      

      e.g. http://<home>:8080/api/v1/oauth/google/callback. The core route dispatches on the plugin prefix of the one-time state nonce to the owning plugin's callback — the same OAuth client then works for every Google plugin (Documents/Sheets, Cameras, …). Legacy per-plugin paths (…/plugins/<name>/oauth/callback) remain as aliases.

    Connecting accounts (admin page #/pui/google_docs)

    • The page shows one Connect Google button per account with an optional label ("personal", "work", "bills") — the label names the account.
    • Click → Google consent opens in a popup; the callback page signals the opener (postMessage 'holai-oauth-done'), closes itself, and the account list refreshes automatically. Popup-only: if the browser blocks the popup, the page shows a hint ("allow popups") instead of navigating away from itself — the admin page never leaves the dashboard.
    • Tokens include a refresh_token (access_type=offline&prompt=consent); access tokens are silently refreshed by the plugin, never shown to clients.
    • Accounts are stored in the central SQLite db (row plugin-google_docs-accounts via ctx.sqlStore, survives plugin updates). Every account answers by its name (label or email, case-insensitive); the first connected is the default.
    • Several accounts: repeat the flow with (or without) a different label.

    Tool surface

    POST /api/v1/tools/google_docs { action, … } (role user; audited):

    action params what happens
    accounts — connected accounts (labels/email) the agent may pick from
    save text, title, account? appends a dated text block to a Google Doc (created by name if missing; newest entry on top)
    record title, values, account? appends a row to a Google Sheet (created by name if missing; keys of values become columns; created sheets get a header row)
    • Explicit docs/x or sheets/d<id> ids jump straight to a known target.
    • Without a connected/authorized account the tool fails with a clear, human-worded error string (plugins never throw raw errors).
    • The dictation feature rides this tool server-side: a long voice recording's transcript is delivered through action save (default title "holai notes") when the user dictates to a document.

    Example: scanned bill

    The agent asks the vision LLM to read the photo (the chat route already attaches a structured note "the user attached an image bill.jpg"), extracts merchant/total/date and calls google_docs { action: "record", title: "bills-2026", values: { vendor: …, total: …, date: … } } — the row lands in the account's default Google Sheet. Any provider filling values from the chat context works.

    Storage details

    Destinations and tokens live only in the central SQLite db (ctx.sqlStore, row plugin-google_docs-accounts). The cameras plugin reuses the exact same Connect-button logic for its Drive clips destination (plugins/cameras).

    Last updated: November 2026