n8n-nodes-google-docs-template
v0.1.7
Published
n8n node to create Google Docs from templates with placeholder replacement
Maintainers
Readme
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 n8nDocker
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-templateGoogle Cloud Setup
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the following APIs:
- Google Docs API
- Google Drive API
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application
- Add authorized redirect URI:
https://your-n8n-url/rest/oauth2-credential/callback - Copy the Client ID and Client Secret
n8n Credential Setup
- In n8n, go to Credentials
- Click Add Credential
- Search for Google Docs Template OAuth2 API
- Enter your Client ID and Client Secret
- Click Sign in with Google and authorize
Usage
Create from Template
- Create a Google Doc template with placeholders like
{{client_name}},{{date}}, etc. - Copy the template's Document ID from the URL:
https://docs.google.com/document/d/DOCUMENT_ID_HERE/edit - Add the Google Docs Template node to your workflow
- Select Create from Template operation
- Enter the Template Document ID
- Enter the new document name
- Add your placeholders (key/value pairs)
Replace Placeholders
- Use this to update an existing document
- Select Replace Placeholders operation
- Enter the Document ID
- 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 buildLicense
MIT
