Skip to content
BlokloDocumentation

Google Docs

Creating and editing Google Docs, for example filling a contract or quote template with data from a form.

Connection type: For the app and the agent. Sign-in: Sign in with a Google account in the provider's window and approve the permissions listed below. No passwords or keys are entered in Bloklo.

How it works

The app and the agent never see the credentials. They call the Google Docs API through the Bloklo gateway, for example fetch("/gw/<connection id>/drive/v3/files"). The gateway appends the path to the address https://docs.googleapis.com, adds an access token from the Google sign-in, renewed automatically, and passes the service's response back to the app.

  • Reads (GET) go through at once. Writes (POST, PUT, PATCH, DELETE) go through at once only when the connection is set to Always allow; otherwise the gateway returns status 202 with an approval_id and the write waits for approval in the panel (see Agent permissions).
  • The Test button sends GET /drive/v3/about?fields=user and checks that the service accepted the credentials.
Note

Some methods run on another host of the same service (noted in the methods table). Choose that host with the X-Bloklo-Host header, for example X-Bloklo-Host: www.googleapis.com; the gateway accepts only the provider hosts allowed in the connector definition.

REST API v1 with JSON bodies. Documents are created and read, and changes are made with one documents.batchUpdate call carrying a list of requests (all or nothing: one invalid request rejects the batch). Listing files, copying a template and exporting to PDF go through Google Drive on another API host (www.googleapis.com); with the drive.file scope only files created or opened by the app are visible.

Before you start

  • A Google account with access to the data the app should use.

Connecting in Bloklo

  1. Open Connectors in the sidebar and find Google Docs.
  2. Click Connect and enter a connection name in Details.
  3. Click Connect. The Google sign-in window opens.
  4. Choose the Google account and approve the permissions. After approval you return to Bloklo and the connection is active.
  5. Attach the connection to a project: Attach to a project… on the connection page, or describe the task in the project chat.
Note

Until Google verifies the Bloklo app, the sign-in window may warn that the app is unverified. To continue, choose Advanced and then Go to bloklo.com. Until then at most 100 Google accounts can connect.

Provider permissions

Bloklo asks Google for exactly these scopes: https://www.googleapis.com/auth/documents, https://www.googleapis.com/auth/drive.file. Access can be revoked at any time by removing the connection in Bloklo or in the Google account settings.

Note

Give the agent a link to the document: Bloklo does not see the list of files on Drive, only documents given by link and those it created itself.

Google Docs documentation

Example prompts

Prompts to type in the chat of a project with the connection attached:

  • “Generate a contract from a Docs template, filling in customer data from the form.”
  • “Append each form submission to the end of a log document.”
  • “Add a button that creates a report in Docs and lets me download it as PDF.”

API methods

The most commonly used Google Docs API methods. The path goes after /gw/<connection id>; parts in braces, such as {id}, are replaced with values. The gateway treats every request other than GET as a write, including queries sent with POST (such as search or GraphQL), so they need approval unless the connection is set to Always allow. The full list of methods is in the provider's documentation.

MethodPathWhat it doesIn the gateway
GET/v1/documents/{documentId}Get a document's contentread
POST/v1/documentsCreate a blank documentwrite (approval)
POST/v1/documents/{documentId}:batchUpdateEdit a document (insert, replace text)write (approval)
GET/drive/v3/filesList Drive files (other API host)read
POST/drive/v3/files/{fileId}/copyCopy a document, e.g. a template (other API host)write (approval)
GET/drive/v3/files/{fileId}/exportExport a document to PDF (other API host)read

Service limits

Reads: 300 per minute per user and 3,000 per minute per project. Writes: 60 per minute per user and 600 per minute per project. Export through Drive: up to 10 MB. Over the limit the response is 429; retry with exponential backoff.

Google Docs API reference

Agent actions and permissions

ActionTypeWhat the agent uses it for
Read datareadFetches data from the service, such as a list of records, to build and check the app. Examples: get a document's content; list Drive files (other API host); export a document to PDF (other API host).
Write datawriteRequests other than GET: creating, changing or deleting data in the service, and also queries sent with POST (such as search). Examples: create a blank document; edit a document (insert, replace text); copy a document, e.g. a template (other API host).
Tip

By default, reads run without asking and writes need approval in the chat. Change this on the connector page or in Settings → Agent permissions (see Agent permissions).

Troubleshooting

The connection says it needs reconnecting

Access was revoked in the Google account, expired, or the password changed. Open the connection and click Authorize.

The test returns HTTP 403

The account has no access to this data, or some permissions were unticked during sign-in. Reconnect and approve all permissions.

Limits and security

  • One connection can make up to 1,000 requests per minute; the service's own limits also apply.
  • Credentials are encrypted and not shown in the browser after saving; only the names of stored fields are visible.
  • A published app works for every visitor: protect the data the connection gives access to with sign-in in the app.

Something unclear or out of date? Contact us