Google Sheets to Google Docs: reviewed row-to-document merge

To turn Google Sheets rows into Google Docs, select approved records, map their fields to a controlled document template, copy that template for each accepted row and inspect the merged text. A reviewed row-to-document merge keeps the original row identity beside the new document identity. In this guide, “mail merge Google Docs” means document generation; email delivery is outside its scope.

The deliverable is one reviewable document per accepted row, plus a reconciliation ledger. For tested form intake and document creation, the form-to-Docs recipe reports 42/42 after accounting for line endings changing from CR+LF into LF. Reading spreadsheet rows, copying a template and merging this batch remain outside that result.

example configuration, not a recorded test. The row-to-document stages are documented in the catalogue; not production-tested by Ai Flowi as this combined pipeline.

1. Prepare a controlled source and template

Connect your Google account for the Sheets, Drive and Docs operations through the Google authorisation guidance. Check the source sheet, template and destination folder individually: permission to read candidate rows says nothing about copying the template or inspecting the resulting documents.

No model is required for this field substitution design. Any added API or model stage needs credentials from your account with that service and incurs its separate charges; consult the service credential reference. Keep the first batch synthetic and review the finished documents before processing permitted operational records.

Choose an immutable source export or freeze the selected rows for the review run. Give every record a stable ID that survives sorting. A spreadsheet row number is a location, not a durable record identity. Record the template revision as well, because changing the template changes what an otherwise identical rerun produces.

Related: Notion To Google Docs; Google Drive integration for AI Flowi Workflow.

2. Declare the row-to-placeholder mapping

For a synthetic training-summary sheet, use the headers record_id, approved, display_name and session_title. The template contains {{display_name}} and {{session_title}}. These names and delimiters are proposed choices to configure and inspect; they are not documented defaults.

For a narrow display, scroll the mapping table horizontally; its focusable region also supports keyboard navigation across columns.

What happens to each proposed source row
RecordSupplied conditionAuthored acceptance target
TRAIN-AApproved, stable ID, both required text fields present.Eligible for one reviewed template copy.
TRAIN-BApproval is absent or explicitly withheld.Exclude before any document copy.
TRAIN-CApproved, but session title is blank.Reject and record the missing field.
TRAIN-A againSame ID appears with conflicting content.Stop that identity for reconciliation; do not choose a row silently.

These are manually specified targets rather than observed merge results. Decide how approval is represented before reading the data. Do not treat a nonempty string such as “no” as an approval simply because it has a value. Preserve identifiers as text and retain the supplied values before any normalization.

3. Configure the available operations

Template Merge performs the row-field substitutions inside an identified document; it must receive the copy ID for the accepted record, rather than the original template ID. The component catalogue separates that operation from Copy File and Loop, so copying and iteration each need their own stage.

Component inputs for the proposed merge
ComponentSet these fieldsInspect this result
Read Rangegoogle_account: authorised account; spreadsheet_id: source sheet; range_name: candidate cells including the header row.values: JSON. Check header order, blank cells and returned envelope.
JSON Operationsdata: inspected range JSON; operations: "JQ Expression"; query: reviewed header mapping and approval/field checks.data_output: JSON containing accepted rows and rejected-row reasons.
Loopdata: reviewed accepted-row Table.item: JSON; done: Table. Confirm the per-item layout and result aggregation.
Copy Filegoogle_account, file_id: controlled template; choose new_name and destination_folder_id.file: JSON. Record the copied file’s actual identifier.
Template Mergegoogle_account, document_id: inspected copy; values: accepted field map. Set prefix, suffix and match_case deliberately.result: JSON. Review the document rather than assuming all intended placeholders matched.
Get Textgoogle_account and the copied document_id.text_data: JSON. It is described as extracting plain text from all tabs.

Read Range JSON and JSON Operations JSON do not directly match Loop’s Table/DataFrame input. Prepare a reviewed Table at this handoff; the example does not invent an automatic conversion. Similarly, Copy File JSON does not directly match Template Merge’s Message-compatible document_id. Inspect and supply the copied ID before merging.

4. Run one row through the review sequence

  1. Read the declared range and compare its header cells with the approved mapping. Stop if required headers are missing, repeated or unexpectedly renamed.
  2. Use JSON Operations to shape and validate the observed payload. Keep rejected records outside the accepted Table; retain their IDs and reasons in the review notes.
  3. Inspect one Loop item before enabling a broader batch. The export provides no complete loop-back recipe or assurance about order, parallelism or retries.
  4. Copy the template for that accepted record. Record the returned copy ID immediately so a later failure does not lose track of a created document.
  5. Set Template Merge to that copy, with a values object containing only the reviewed replacement fields. Confirm placeholder spelling and selected tab scope.
  6. Use Get Text and open the copy. Compare the substituted text with the row and check layout before marking the record reviewed.

Keep each review handoff explicit until a controlled editor run proves the response shapes. A field called id belongs to the response being inspected; check each following component separately before choosing its identifier mapping. There is no verified paste-and-run mapping for this entire sequence.

5. Preserve a result ledger and reconcile reruns

For each selected identity, record the source revision, template revision, copied document ID, merge status, read-back review and next action. Distinguish “not started,” “copy recorded,” “merge uncertain” and “reviewed.” These are proposed ledger states, not native workflow status values.

If a merge fails after copying, the copy may still exist. If the response is lost after a write, inspect that recorded document before retrying. A retry that starts at Copy File can create another document. Reusing a title is not evidence of deduplication, and this proposal has no atomic batch transaction or durable idempotency mechanism.

On rerun, compare record ID and both revisions with the ledger. Resume or replace a known copy only after a reviewer resolves its state. An external ledger needs its own persistence and access rules; Loop’s Done Table by itself cannot establish how to recover the batch after an interruption.

6. How do I check unresolved placeholders and partial failures?

Test a missing value, a misspelled placeholder, a repeated placeholder, braces inside literal source text and a later-row failure. Search the reviewed document for the chosen delimiters, then compare each suspected leftover against the template: source text may legitimately contain braces. Get Text supports content inspection, while opening the document checks formatting and tab placement.

Do not mark the whole batch complete because one document looks correct. Reconcile every accepted record against its document ID and review decision, and keep rejected records separate. Use a manual copy and paste when the batch is small enough that maintaining recovery state would add unnecessary work.

Plans: Go from USD8/month billed yearly (USD10 monthly), Plus from USD16 (USD20 monthly), Pro 100 from USD80 (USD100 monthly), Pro 200 from USD160 (USD200 monthly) and Pro 500 from USD400 (USD500 monthly), with 5,000 to 250,000 Flowi Tokens/month and top-ups; 1 token per node run; third-party API and model usage is not included.

Review actual executions across reads, validation, iteration, copies, merges and read-back. This design reports neither automatic email sending nor successful unattended batch processing.

By Ai Flowi · Published .