Create Document from Template

📝 Definition

The "Create Document from Template" action in the Google Document category allows you to generate new Google Docs, HTML, or PDF files by using a predefined Google Docs template containing placeholders (e.g., {{x}}). These placeholders can be dynamically replaced with text, images, or tables using data from previous steps in your flow. This action is ideal for automating the creation of personalized documents such as contracts, reports, letters, or invoices. Key capabilities include text replacement, image embedding, and dynamic table population—all fully customizable and adaptable to your workflow needs.


Example Use Cases:


📄 Employee Onboarding Documents

Automatically generate personalized welcome letters, contracts, or policy documents for new hires using data from HR systems or forms.


🧾 Invoice Generation

Create professional-looking invoices with customer, product, and pricing details pulled from CRM or spreadsheet data.


📝 Client Proposals

Build customized proposals or quotes by merging deal information, contact details, and pricing tables from tools like HubSpot or Google Sheets.


📋 Meeting Summaries or Reports

Generate structured meeting notes or status reports using form submissions or project updates collected via workflows.


📃 NDAs and Agreements

Automatically populate and send out NDAs or service agreements with signer details and terms pulled from your CRM or submission forms.


Inputs:


🧩 Inputs

The "Create Document from Template" action uses your existing Google Docs file as a template and dynamically fills it with data such as text, images, and tables. Below are the main input fields required to configure this action.


🔗 Connection

This is your authenticated Google account connection. Zenphi uses this to access your Google Drive and manage the template and output files. Make sure the connection has access to the Google Doc template and the destination folder.


📄 File Id

The File Id refers to the unique identifier of the Google Docs template that you want to use. You can find this in the URL of your Google Doc — it's the string between /d/ and /edit. This tells Zenphi which template to use for document generation.

*Example:*In the URL https://docs.google.com/document/d/1A2B3C4D5E6F7G8H9I/edit, the File Id is 1A2B3C4D5E6F7G8H9I.


📁 Destination Folder Id

This field specifies where the generated document should be saved in Google Drive. The Folder Id is a unique identifier for the destination folder — similar to the File Id, it's found in the Google Drive URL.

*Tip:*Copy the folder ID from the URL of your Google Drive folder.


📝 New Document Filename

This sets the name of the newly created document. You can type a static filename (e.g., "Employee Onboarding - John Smith") or use dynamic content like variables and tokens (e.g., using a person’s name or date) to auto-generate file names.


🌐 Generate HTML

Enable this option if you want to generate an HTML version of the output document in addition to the Google Doc or PDF. This is useful for embedding documents in emails or web pages.


📄 Generate PDF

Enable this if you'd like to export the final document as a downloadable PDF file. You can generate both a Google Doc and a PDF version from the same template if needed.


🧩 Mapping Sections

Once the main template and output settings are defined, you'll configure how data fills your document using the following three sections:


✏️ Placeholder Mapping (for text replacement)

Used for replacing text-based placeholders in your template.

  • Placeholder:The tag (e.g., {{ employee_name }}) in your template where the value should appear. These should match exactly with what you place in the Google Doc.

  • Value:The actual data that replaces the placeholder — this can be pulled from previous steps (form input, spreadsheet row, etc.) or typed manually.

Example:{{ start_date }} → "01/06/2025"


🖼️ Image Mapping (for image replacement)

Used to replace image placeholders within your template with actual images.

  • Placeholder:The tag (e.g., {{ employee_photo }}) placed inside the title field of the image’s ALT text in Google Docs. This helps Zenphi find and replace it.

  • Image Payload:The image you want to insert. This could be a file uploaded via form, pulled from a storage system, or a URL converted to an image file.

*Tip:*Make sure the placeholder is set properly in the image's ALT text, not in the body of the document.


📊 Table Mapping (for dynamic tables)

Used to insert a full table of data (such as product line items or a list of employees) into your document.

  • Table Name:The table identifier inside your Google Doc — place the placeholder (e.g., {{ products_table }}) in the top-left cell of the table. Zenphi uses this to find the table in the template.

  • Table Items:The list of data rows to insert — this can be pulled from a Zenphi Table, Google Sheet, Excel file, form responses, etc. Each item becomes a row in the output table.

  • Placeholder:Each column in the template table should have its own placeholder in the second row (header), which matches a property from your data.

  • Value:Here, you map each column from your data source to the corresponding placeholder in the template. For example, map the "price" column in your data to {{ price }} in your template.

  • Has Footer:Turn this ON if the table in your template includes a footer row (e.g., totals or summary). Zenphi will preserve this row and not overwrite it with dynamic data.



🧭 Step-by-Step Guide

This step-by-step guide walks you through how to use the Create Document from Template action to generate a Google Doc (or PDF/HTML version) using placeholders for text, images, and a dynamic table. We'll demonstrate how to set up the template and configure the action in your Zenphi flow.


📝 Step 1: Prepare Your Google Docs Template

Create or open a Google Docs file that will act as your template. You’ll define three types of placeholders:

1. Text Placeholders

Use double curly braces to define placeholders for text.Example:

  • {{title}}
  • {{client_name}}
  • {{date}}

These will be replaced by values you define in the Zenphi action.

2. Image Placeholders

To insert an image dynamically:

  • Add an image to the doc.
  • Right-click the image > Alt text.
  • Set the Title to a unique placeholder like: {{logo}}.

Zenphi will use this to identify and replace the image.

3. Table Placeholder

Create a table with exactly 2 rows:

  • First row: Table headers and the table name placeholder in the top-left cell (e.g., {{products_table}})
  • Second row: Placeholder tags for dynamic fields in each columnExample: {{product_name}}, {{price}}, {{quantity}}

🧾

Note: You can optionally include a third row for a footer (like total or summary), and enable the “Has Footer” toggle later in Zenphi. But in this walkthrough, we’ll keep it to just 2 rows.


🧩 Step 2: Add the Action to Your Zenphi Flow

  1. In your flow, drag the Create Document from Template action from the Google Document category.

  2. Fill in the input fields:

    • Connection – Select your authenticated Google account.
    • File Id – Copy the ID from your Google Docs template URL and paste here.
    • Destination Folder Id – Select or paste the ID of the folder where the output document should be saved.
    • New Document Filename – Choose a name (e.g., Client Quote {{client_name}}).
    • Toggle on Generate PDF and/or Generate HTML if needed.

🏷️ Step 3: Map Text Placeholders

Under the Placeholder Mapping section:

  • For each text placeholder (e.g., {{title}}, {{date}}):

    • Placeholder: Enter without curly braces – e.g., title
    • Value: Choose the dynamic value using Token Picker or enter static text

Example:

PlaceholderValue
title"Client Proposal"
dateCurrent date token
client_nameForm Response.Name

🖼️ Step 4: Map Image Placeholders

Under the Image Mapping section:

  • Placeholder: Enter the title of the image's ALT text (e.g., logo)
  • Image Payload: Use a file URL or image token from a previous step (e.g., uploaded logo from a form)

📊 Step 5: Configure Table Mapping

  1. Table Name: Enter the placeholder (from the first cell of the table), e.g., products_table.

  2. Table Items: Provide a collection of items (e.g., rows from a Google Sheet, Zenphi Table, or form submissions). Each item will create one row.

  3. Under the table mapping section, add a row for each column placeholder:

PlaceholderValue
product_nameCurrentItem.ProductName
priceCurrentItem.Price
quantityCurrentItem.Quantity

Use Token Picker to select each property from the item collection.

  1. Has Footer: If your template table has a third row for totals or footnotes, toggle this ON. In this example, we’re keeping it OFF.

▶️ Step 6: Run and Review

  1. Save and publish your flow.

  2. Trigger or manually run the flow.

  3. The action will:

    • Replace all text and image placeholders.
    • Populate the table with rows from your data source.
    • Generate a new Google Doc, and optionally a PDF/HTML version, saved to your selected folder.


📤 Outputs

After the action runs successfully, it provides several outputs based on your selected options:

  • HTML File – The HTML version of the document (available only if Generate HTML is enabled).
  • PDF File ID – The unique ID of the generated PDF file.
  • PDF View Link – A URL to preview the PDF in a browser.
  • PDF Download Link – A direct link to download the PDF file.
  • PDF File – The raw content of the PDF (available only if Generate PDF is enabled).
  • File ID – The unique ID of the generated Google Doc file.
  • File Name – The name you specified for the generated document.
  • View Link – A link to view the document in Google Docs.
  • Download Link – A link to download the document as a file.

These outputs can be used in follow-up actions such as sending emails, saving records, or logging activities.



📘 Example Scenario: Generate a Team Report Using a Zenphi Table

Let’s walk through a practical example where we generate a report document using data from a Zenphi Table. The document will include a dynamic table populated with names and ages, and also show when the document was generated.


🗂 Template Setup in Google Docs

We first design a Google Docs template that includes a table structured like this:

{{Table1}}AgeCreatedAt
{{C1}}{{C2}}{{C3}}
  • First Row (Headers):

    • First cell includes the table name placeholder: {{Table1}}
    • Other cells serve as column headers: Age, CreatedAt
  • Second Row (Placeholders):

    • {{C1}}: Placeholder for the name
    • {{C2}}: Placeholder for the age
    • {{C3}}: Placeholder for the created time

⚙️ Flow Configuration in Zenphi

  1. Retrieve the DataIn your flow, use an action (like “Get Records” from Zenphi Table) to retrieve a list of people with their Name and Age.Let’s call this list: TeamData.

  2. Generate Current TimeAdd an action (e.g., “Get Current Date Time”) to capture the current timestamp to use later for CreatedAt.

  3. Configure Create Document from Template Action

    • Connection: Connect your Google account
    • File Id: Enter the ID of your Docs template
    • Destination Folder Id: Where the generated document should go
    • New Document Filename: For example: Team Report - {{ExecutionDate}}
    • Toggle on Generate PDF (optional)
  4. Table Mapping Section

    • Table Name: Enter Table1 (from the first cell in the template table)
    • Table Items: Assign TeamData (the list retrieved earlier)
  5. Placeholder Mapping in Table Section

    PlaceholderValue Assignment
    C1Use Select PathItem.Name
    C2Use Select PathItem.Age
    C3Use Token Picker → Current Date Token
    table1Hard coding 'Name' (simple text replacemnet for table identifier)

    This setup ensures each row in the output document will show the person’s name, age, and the exact time the document was generated.

  6. Run the FlowWhen the flow runs, it will:

    • Loop through each record in TeamData
    • Replace placeholders in the document table with actual values
    • Add one row per person, including the current time in the final column
    • Save the file in your selected Drive folder

This example highlights how you can blend static text, dynamic lists, and even runtime-generated values (like current time) into a fully automated document creation process using Zenphi.

🖥️

For a full implementation demo, check out our YouTube video.