Appearance
Google Docs integration
Google Docs is Google's collaborative document editor. This integration lets your WeWeb backend generate documents from templates with placeholder replacement (mail-merge), replace and append text, insert images, read document content, create blank documents in Shared Drives, and export documents as PDF, Markdown, plain text or Word, using a service account.
Use cases
- Generate invoices, contracts, or reports by copying a template and filling in
{{placeholder}}values. - Export a generated document as a PDF and email it or store it from the same workflow.
- Append entries (logs, meeting notes, submissions) to the end of a running document.
- Read a document's text into a workflow to process or display it in your app.
- Update standard text across a document (for example a status or a date) with Replace Text.
Setup
Google Docs authenticates with a Google Cloud service account. You create the account once, download its JSON key, and share your documents with its email address, the same way you would share them with a person.
- Sign in to Google Cloud Console.
- Create a project or select an existing one.
- Enable the Google Docs API and the Google Drive API (Drive powers copying templates, creating documents, and exports).
- Go to
IAM & Admin→Service Accountsand clickCreate service account. - Name the service account and click
Create and continue, then skip role assignment and clickDone. - Open the service account menu (three dots) →
Manage keys→Add key→Create new key→JSON, then download the key file. - In WeWeb, open
Data & API→Integrations, selectGoogle Docs, and clickAdd Connection. - Click
Upload JSON Keyto auto-fill the connection, or fill the fields manually:Client Email, The service account email from the JSON key (client_email)Private Key, The private key from the JSON key (private_key)
- Share the documents or templates you want to use with the service account email (viewer access for reading and exporting, editor access for text edits).
- To create documents (blank or from a template), add the service account as a
Content managermember of a Shared Drive. Shared Drives require Google Workspace. - Test with the simplest action: share any document with the service account and run
Get Document Text. If it returns the text, the connection works.
How document access works
The rule that shapes everything in this integration: service accounts cannot own files.
- Reading, editing, and exporting work everywhere. Any Google Doc shared with the service account email can be read, edited, merged, and exported, including documents and templates in a personal (free Gmail) My Drive.
- Creating documents requires a Shared Drive.
Create Blank DocumentandCreate Document from Templatemust target a Shared Drive (or a folder inside one) where the service account is a member. Targeting a My Drive folder, even one shared with the service account, fails with a403storageQuotaExceedederror, because the new file would be owned by the service account, which has no storage quota. Shared Drives only exist on Google Workspace plans.
Every document is identified by its document ID: the long ID in the document URL, between /d/ and /edit (docs.google.com/document/d/<ID>/edit).
How text edits work
Google's document model is index-based: a document is a tree of structural elements (paragraphs, tables, section breaks), and every element carries a startIndex and endIndex locating it in the text. You can see this model in the output of Get Document. See Google Docs API - Document structure for the full model.
You never supply indexes yourself. The WeWeb actions avoid them on purpose, because indexes shift every time the document changes:
Append TextAndInsert Imagealways target the end of the document body.Replace TextAnd the replacements inCreate Document from Templatereplace every occurrence of a search text, wherever it appears: all tabs, headers, footers, and table cells.
Placeholders and replacements
The Replacements input is an object mapping search text to replacement value, for example { "{{name}}": "Jane Doe", "{{date}}": "2026-09-15" }.
Keys are matched as literal text. The {{name}} braces are a naming convention, not template syntax: if your document contains {{name}}, the key must include the braces. A key without braces replaces every bare occurrence of that word anywhere in the document, so prefer wrapped placeholders in templates.
Both replacement actions return occurrencesChanged, a per-key count of how many occurrences were replaced. A count of 0 usually means a typo or a case mismatch in the key.
Export formats
Export Document converts a Google Doc and returns it as a base64 string, ready to pass to a file upload, an email attachment, or a download. Four formats are available: PDF (application/pdf), Markdown (text/markdown), plain text (text/plain), and Word (application/vnd.openxmlformats-officedocument.wordprocessingml.document).
Google caps exports at a hard 10 MB, and the base64 response payload makes roughly 4 to 5 MB the practical cap. Oversize exports fail with an error.
Only files with the Google Docs type can be exported or read as text. PDFs, uploaded Word files, and other Drive files are rejected.
Common pitfalls (setup & usage)
Creating a document fails with storageQuotaExceeded
The destination is a My Drive folder. Service accounts cannot own files, so Google rejects the creation even if the folder is shared with the service account. Create the document in a Shared Drive (or a folder inside one) where the service account is a member with Content manager access.
The Destination Folder dropdown is empty
The dropdown lists the Shared Drives the service account is a member of. If it is empty, the service account has not been added to any Shared Drive yet. Add it as a member in Google Drive, then click the refresh icon next to the field. Shared Drives require Google Workspace.
A replacement changed 0 occurrences
Keys are matched as literal, case-sensitive text by default. Check that the key includes the braces if the document uses {{placeholder}} style, and that the spelling and casing match the document exactly. Create Document from Template always matches case-sensitively; on Replace Text you can turn Match Case off.
Document not accessible
If an action cannot find or open the document, the document has usually not been shared with the service account email (Client Email). Share it like you would with a person: viewer access is enough for Get Document, Get Document Text and Export Document; editor access is required for Replace Text, Append Text and Insert Image.
Export or read fails on a file that is not a Google Doc
Export Document and Get Document Text only work on Google Docs documents (application/vnd.google-apps.document). A PDF or an uploaded .docx stored in Drive is a different file type and is rejected.
The two actions report it differently. Export Document checks the file type before calling Google and fails with a WeWeb message naming the file and its actual type ("… is not a Google Doc"). Get Document Text has no such check: it asks Google directly, so what you get back is Google's own error.
Insert Image fails on a valid-looking URL
Google's servers fetch the image, so the URL must be publicly accessible (no authentication, no localhost), at most 2 kB long, and point to a PNG, JPEG or GIF under 50 MB and at most 25 megapixels. Signed URLs (e.g. from a private bucket) often exceed the 2 kB URL cap.
All Actions
Actions are grouped by what they do to the document. Each action name links to its details below.
Create documents
| Action | Description |
|---|---|
| Create Blank Document | Create an empty Google Doc in a Shared Drive folder. |
| Create Document from Template | Copy a template into a Shared Drive folder and replace its placeholders (mail-merge). |
Edit content
| Action | Description |
|---|---|
| Replace Text | Replace every occurrence of one or more text snippets in an existing document. |
| Append Text | Append plain text at the end of the document body. |
| Insert Image | Insert an inline image at the end of the document body from a public URL. |
Read and export
| Action | Description |
|---|---|
| Get Document Text | Read the full document content as plain text. |
| Get Document | Get the raw Google Docs document JSON for advanced processing. |
| Export Document | Convert the document to PDF, Markdown, plain text or Word and return it as base64. |
Action details
Create Blank Document
Create an empty Google Doc in a Shared Drive folder; combine with Append Text or Replace Text to fill it.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document Name | Meeting Notes | Name of the new document. | Required |
Destination Folder | 0AIabCdEfGhIjUk9PVA | Where to create the document: pick a Shared Drive (its root) from the list, or bind the ID of a folder inside a Shared Drive. | Required. Must be in a Shared Drive; My Drive folders fail with storageQuotaExceeded |
Example output
json
{
"documentId": "1AbC9DeFgHiJkLmNoPqRsTuVwXyZ",
"name": "Meeting Notes",
"webViewLink": "https://docs.google.com/document/d/1AbC9DeFgHiJkLmNoPqRsTuVwXyZ/edit?usp=drivesdk"
}Documentation of API endpoint that powers action: Google Drive API - files.create (POST /drive/v3/files)
Create Document from Template
Copy a template Google Doc into a Shared Drive folder, then replace its {{placeholder}} text with the provided values (mail-merge).
The template can live anywhere the service account can read, including a template in someone's My Drive shared with it. The destination must be a Shared Drive, because the copy is owned by whoever makes it, and service accounts cannot own files.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Template Document ID | 17gDzjoM9SAUGELlH4zZavJNESifNgZYkTuOSfIxCLO0 | Document ID of the template to copy (the long ID from the document URL). | Required. Template must be shared with the service account |
Document Name | Invoice #123 - Acme Corp | Name of the generated document. | Required |
Destination Folder | 0AIabCdEfGhIjUk9PVA | Where to create the generated document: a Shared Drive (its root) from the list, or the ID of a folder inside a Shared Drive. | Required. My Drive destinations fail with storageQuotaExceeded |
Replacements | {"{{name}}":"Jane Doe","{{date}}":"2026-09-15"} | Placeholder values as key-value pairs; each key is the literal text to search for in the template. Include the braces when the template uses {{placeholder}} style. | Required. Matching is case-sensitive and covers all tabs, headers, footers and table cells |
Example output
json
{
"documentId": "1XyZ8WvUtSrQpOnMlKjIhGfEdCbA",
"name": "Invoice #123 - Acme Corp",
"webViewLink": "https://docs.google.com/document/d/1XyZ8WvUtSrQpOnMlKjIhGfEdCbA/edit?usp=drivesdk",
"occurrencesChanged": {
"{{name}}": 1,
"{{date}}": 2
}
}occurrencesChanged counts how many times each search text was replaced; 0 for a key usually means a typo or a case mismatch.
Documentation of API endpoint that powers action: Google Drive API - files.copy (POST /drive/v3/files/{fileId}/copy) and Google Docs API - documents.batchUpdate (replaceAllText)
Replace Text
Replace every occurrence of one or more literal text snippets in an existing Google Doc (mail-merge on a document in place).
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to edit (the long ID from the document URL). The service account needs editor access. | Required |
Replacements | {"{{status}}":"Approved"} | Text replacements as key-value pairs; each key is the literal text to search for and its value is the replacement. | Required, at least one entry. Applies across all tabs, headers, footers and table cells |
Match CaseOptional | true | Whether the search is case-sensitive. | Default true |
Example output
json
{
"documentId": "1AbC9DeFgHiJkLmNoPqRsTuVwXyZ",
"occurrencesChanged": {
"{{status}}": 3
}
}Documentation of API endpoint that powers action: Google Docs API - documents.batchUpdate (replaceAllText)
Append Text
Append plain text at the end of the body of a Google Doc; newlines in the text start new paragraphs.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to append to (the long ID from the document URL). The service account needs editor access. | Required |
Text | Meeting notes - 15 Sep 2026 | Plain text appended at the end of the document body. Use newlines (\n) to start new paragraphs. | Required |
Example output
json
{ "documentId": "1AbC9DeFgHiJkLmNoPqRsTuVwXyZ" }Documentation of API endpoint that powers action: Google Docs API - documents.batchUpdate (insertText)
Insert Image
Insert an inline image at the end of the body of a Google Doc, fetched by Google from a publicly accessible URL.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to insert the image into (the long ID from the document URL). The service account needs editor access. | Required |
Image URL | https://example.com/logo.png | URL of the image, fetched by Google's servers; it must be publicly accessible (no auth, no localhost). | Required. URL at most 2 kB long; image PNG, JPEG or GIF, under 50 MB and at most 25 megapixels |
Example output
json
{ "documentId": "1AbC9DeFgHiJkLmNoPqRsTuVwXyZ" }Documentation of API endpoint that powers action: Google Docs API - documents.batchUpdate (insertInlineImage)
Get Document Text
Read the full content of a Google Doc as plain text (all tabs, without formatting).
Only Google Docs documents can be read this way, not PDFs or other file types. Viewer access is enough.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to read (the long ID from the document URL). | Required. Google Docs documents only |
Example output
json
{ "text": "Invoice #123\nCustomer: Jane Doe\nTotal: $250.00\n" }Documentation of API endpoint that powers action: Google Drive API - files.export (GET /drive/v3/files/{fileId}/export)
Get Document
Get the raw Google Docs document JSON (title, tabs, structural elements, named ranges, inline objects) for advanced processing.
All tabs are included in the response. For plain text content, prefer Get Document Text.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to fetch (the long ID from the document URL). Viewer access is enough. | Required |
Suggestions View ModeOptional | PREVIEW_SUGGESTIONS_ACCEPTED | How pending suggested edits are rendered in the returned document. | Valid: DEFAULT_FOR_CURRENT_ACCESS, PREVIEW_SUGGESTIONS_ACCEPTED, PREVIEW_WITHOUT_SUGGESTIONS. Google uses DEFAULT_FOR_CURRENT_ACCESS when omitted |
Example output (truncated)
json
{
"documentId": "1AbC9DeFgHiJkLmNoPqRsTuVwXyZ",
"title": "Invoice #123",
"tabs": [
{
"tabProperties": { "tabId": "t.0", "title": "Tab 1" },
"documentTab": {
"body": {
"content": [
{
"startIndex": 1,
"endIndex": 13,
"paragraph": { "elements": [ "…" ] }
}
]
}
}
}
]
}Content lives under tabs[i].documentTab: for example, inline objects are at tabs[0].documentTab.inlineObjects, not at the document root. Each structural element carries startIndex and endIndex positions, per the index model described in How text edits work.
Documentation of API endpoint that powers action: Google Docs API - documents.get (GET /v1/documents/{documentId})
Export Document
Convert and download a Google Doc in another format (PDF, Markdown, plain text or Word) as a base64 string.
Only Google Docs documents can be exported; other file types are rejected with an explicit error. Viewer access is enough.
Inputs
| Display Key | Example Input | Description | Restrictions |
|---|---|---|---|
Document ID | 1AbC9DeFgHiJkLmNoPqRsTuVwXyZ | Document ID to export (the long ID from the document URL). | Required. Google Docs documents only |
Export Format | application/pdf | Target format for the export. | Required. Valid: application/pdf, text/markdown, text/plain, application/vnd.openxmlformats-officedocument.wordprocessingml.document (Word .docx) |
Example output
json
{
"name": "Invoice #123",
"mimeType": "application/pdf",
"base64": "JVBERi0xLjQKJcTl…"
}Google caps exports at 10 MB; the base64 response payload makes roughly 4 to 5 MB the practical cap.
Documentation of API endpoint that powers action: Google Drive API - files.export (GET /drive/v3/files/{fileId}/export)
Error handling
Google API errors pass through to the workflow result as-is, with the original message and error details (including domain, reason and location) intact, so you can act on the exact Google reason. On top of that, WeWeb raises its own instructional messages before calling Google in three cases: a connection with a missing or incomplete Client Email or Private Key, Replace Text with an empty Replacements object, and Export Document on a file that is not a Google Doc.
| Error code and type | Reason |
|---|---|
| 400 Bad Request | Invalid parameters, for example an image URL that Google cannot fetch or an unsupported image format. |
| 401 Unauthorized | Invalid credentials: wrong Client Email or malformed Private Key. |
| 403 Forbidden | The document is not shared with the service account, a required API (Docs or Drive) is not enabled in the Google Cloud project, or the reason is storageQuotaExceeded: a create action targeted a My Drive folder instead of a Shared Drive. |
| 404 Not Found | The document ID does not exist, or the file is not visible to the service account. |
| 429 Too Many Requests | Google API rate limit reached; retry with backoff. |
| 500 Internal Server Error | Google-side error; retry with backoff. |
FAQs
How do I find the document ID?
Copy it from the document URL, between /d/ and /edit: docs.google.com/document/d/<ID>/edit.
Why do I get storageQuotaExceeded when creating a document?
The destination is a My Drive folder. Service accounts have no storage quota and cannot own files, so Google rejects the new file even if the folder is shared with the service account. Point Destination Folder at a Shared Drive (or a folder inside one) where the service account is a member.
Do I need Google Workspace?
Only for creating documents: Shared Drives exist only on Google Workspace plans, and the create actions require one. Reading, editing, merging and exporting work with any Google account, including free Gmail, as long as the document is shared with the service account email.
Why is the Destination Folder dropdown empty?
The dropdown lists the Shared Drives the service account belongs to. Add the service account as a member of a Shared Drive (as Content manager or above), then click the refresh icon next to the field.
Why did my placeholder not get replaced?
Replacement keys are matched as literal, case-sensitive text. If the document contains {{name}}, the key must be {{name}} with the braces, spelled and cased exactly as in the document. Check occurrencesChanged in the action output: a 0 for a key means it was not found.
Can I read or export a PDF or Word file stored in Drive?
No. Get Document Text and Export Document only work on Google Docs documents. To use an uploaded Word file, open it in Google Docs and save it as a Google Doc first, then use that document's ID.
How do I generate a PDF from a template?
Run Create Document from Template with your placeholder values, then pass the returned documentId to Export Document with Export Format set to application/pdf. The base64 in the output is the PDF file content, ready for a download, an upload, or an email attachment.
Why does Insert Image reject my image URL?
Google's servers fetch the image, so the URL must be publicly reachable without authentication, at most 2 kB long, and point to a PNG, JPEG or GIF under 50 MB and at most 25 megapixels. Signed URLs from private storage often exceed the 2 kB cap; use a short public URL instead.

