Graphrt

Google Docs

Read documents (with tabs), create, insert text, replace text for templates, raw batch updates behind an opt-in (OAuth or service account)

Beta v0.1.0 Node.js 6 actions
Use in Graphrt Desktop

About

A Graphrt plugin for the Google Docs API v1: read documents (including tabs), create documents, insert text, replace text everywhere (fill templates) and send raw batch updates. To find documents by name, copy, share or export them use google-drive.

What it can do

  • get_document: structure and text, include_tabs_content returns every tab, suggestions_view_mode chooses how suggestions appear
  • create_document: a new empty document with a title
  • insert_text: at a UTF-16 index (1 = start of the body), or appended at the end
  • replace_all_text: every occurrence with replace_with, optionally case-sensitive and limited to tabs, reports occurrencesChanged. Deleting the matches needs an explicit delete_matches: true (a missing or empty replace_with is refused, never treated as "delete")
  • batch_update: any batchUpdate requests (styles, tables, images, deletions)
  • api_request: any other endpoint (GET only for agents)

Actions

Each action is a step you can add to a workflow. Agents can also use most of them as tools.

  • Get document google-docs.get_document
  • Create document google-docs.create_document
  • Insert text google-docs.insert_text
  • Replace text google-docs.replace_all_text
  • Batch update google-docs.batch_update
  • Google Docs API request google-docs.api_request

Settings

Graphrt starts plugins with a clean environment. Only these values reach the plugin, and secrets stay out of logs.

  • GOOGLE_REFRESH_TOKEN
    OAuth refresh trio
  • GOOGLE_SERVICE_ACCOUNT_JSON
    Path to a service account key file (scope documents), share each document with the service account's email
  • GOOGLE_ACCESS_TOKEN
    A ready access token (used only when neither of the above is set)
  • GOOGLE_DOCS_TOOL_ALLOW_BATCH_UPDATE
    1 lets agent tools call batch_update and delete text with replace_all_text delete_matches
  • GOOGLE_CLIENT_ID
  • GOOGLE_CLIENT_SECRET
  • GOOGLE_DOCS_TOOL_TOKEN_SOURCE

How to use it

In Graphrt Desktop

  1. Open Plugins and search for Google Docs.
  2. Click Install and approve it.
  3. Follow the setup steps on the plugin's page, then paste the settings it needs.
  4. Describe a job that needs it, and the builder adds the steps.
Plugins in Graphrt Desktop

With the CLI

terminal
$ graphrt plugin install google-docs
workflow.yaml
# Fill a template copy (copy it first with google-drive.copy_file)
- id: fill
  type: google-docs.replace_all_text
  document_id: "{{#copy.data.id#}}"
  find: "{{customer_name}}"
  replace_with: "{{#start.customer#}}"
- id: note
  type: google-docs.insert_text
  document_id: "{{#copy.data.id#}}"
  text: "\nGenerated by graphrt."
Plugins in the docs