google-docs-template

n8n node to create Google Docs from templates with placeholder replacement

Package Information

Downloads: 39 weekly / 51 monthly
Latest Version: 0.1.7
Author: LLMPRO

Documentation

n8n-nodes-google-docs-template

Custom n8n node for creating Google Docs from templates with placeholder replacement.

Features

  • Create from Template: Copy a Google Doc template and replace placeholders in one operation
  • Replace Placeholders: Update placeholders in an existing document
  • Multiple placeholder formats: {{var}}, ${var}, [var], {var}, <<var>>
  • Case-sensitive matching: Optional case sensitivity for placeholder matching
  • Destination folder: Specify where to save the new document

Installation

Local Development

# Install dependencies
npm install

# Build the project
npm run build

# Link to n8n (run from this project directory)
npm link

# Then in your n8n custom nodes directory (~/.n8n/custom or equivalent)
npm link n8n-nodes-google-docs-template

# Restart n8n

Docker

Add to your Dockerfile:

FROM n8nio/n8n

# Copy the built node
COPY dist /home/node/.n8n/custom/n8n-nodes-google-docs-template/dist
COPY package.json /home/node/.n8n/custom/n8n-nodes-google-docs-template/

Community Node (npm)

# In your n8n instance
npm install n8n-nodes-google-docs-template

Google Cloud Setup

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Enable the following APIs:
    • Google Docs API
    • Google Drive API
  4. Go to APIs & Services > Credentials
  5. Click Create Credentials > OAuth client ID
  6. Select Web application
  7. Add authorized redirect URI: https://your-n8n-url/rest/oauth2-credential/callback
  8. Copy the Client ID and Client Secret

n8n Credential Setup

  1. In n8n, go to Credentials
  2. Click Add Credential
  3. Search for Google Docs Template OAuth2 API
  4. Enter your Client ID and Client Secret
  5. Click Sign in with Google and authorize

Usage

Create from Template

  1. Create a Google Doc template with placeholders like {{client_name}}, {{date}}, etc.
  2. Copy the template's Document ID from the URL:
    https://docs.google.com/document/d/DOCUMENT_ID_HERE/edit
  3. Add the Google Docs Template node to your workflow
  4. Select Create from Template operation
  5. Enter the Template Document ID
  6. Enter the new document name
  7. Add your placeholders (key/value pairs)

Replace Placeholders

  1. Use this to update an existing document
  2. Select Replace Placeholders operation
  3. Enter the Document ID
  4. Add your placeholders

Example Workflow

{
  "nodes": [
    {
      "name": "Google Docs Template",
      "type": "n8n-nodes-google-docs-template.googleDocsTemplate",
      "parameters": {
        "operation": "createFromTemplate",
        "templateId": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
        "newDocumentName": "Contract_{{ $json.client_name }}_2024",
        "placeholders": {
          "placeholder": [
            { "key": "client_name", "value": "={{ $json.client_name }}" },
            { "key": "date", "value": "={{ $now.format('MMMM D, YYYY') }}" },
            { "key": "amount", "value": "={{ $json.contract_amount }}" }
          ]
        }
      }
    }
  ]
}

Output

The node returns:

{
  "success": true,
  "operation": "createFromTemplate",
  "documentId": "new-document-id",
  "documentName": "Contract_ClientName_2024",
  "documentUrl": "https://docs.google.com/document/d/new-document-id/edit",
  "templateId": "original-template-id",
  "destinationFolderId": "folder-id-or-root",
  "placeholdersProvided": 3,
  "replacementsMade": 15
}

Development

# Watch mode for development
npm run dev

# Lint
npm run lint

# Fix lint issues
npm run lintfix

# Build for production
npm run build

License

MIT

Discussion