What This Workflow Does
This workflow takes form submissions and turns them into ready Google Docs contracts fast.
It copies a Google Docs template, replaces placeholders with the form data, and creates a personalized document immediately.
This cuts down hours of manual work and avoids errors like missing or wrong information.
Tools and Services Used
- n8n.io: Runs automation workflows and integrates services.
- Google Drive: Stores and copies the Google Docs template files.
- Google Docs API: Edits document content by replacing placeholder text.
- Form Trigger Node in n8n: Captures client inputs from a web form.
- Google OAuth2 Credentials: Allows access to Google Drive and Docs securely.
Inputs, Processing Steps, and Output
Inputs
- Client fills out a web form set up inside n8n using Form Trigger.
- Form fields include required data like
nameand optionally more fields like address or email.
Processing Steps
- The workflow copies a predefined Google Docs template in Google Drive via Google Drive copy operation.
- A Code node extracts form fields into key-value pairs for processing.
- Another Code node formats the key-values as “replaceAllText” requests for Google Docs API.
- The HTTP Request node calls Google Docs API to replace placeholders (like {{name}}) with the form values inside the copied document.
Output
The final output is a personalized Google Docs document copied and updated in Google Drive, ready instantly after submission.
Beginner step-by-step: How to use this workflow in n8n
Importing the workflow
- Download the workflow file using the Download button on this page.
- Open the n8n editor where the workflow will be used.
- Choose Import from File in n8n and select the downloaded workflow file.
Setup after import
- Add OAuth2 Credentials for Google Drive and Google Docs nodes using your Google account with proper access.
- Update the Google Drive node’s
File IDwith your template file ID if different. - If more form fields were added, ensure your Google Docs template has matching placeholders with double curly braces, e.g., {{address}}, {{email}}.
- Add Basic Authentication settings in the Form Trigger node to protect the form from unauthorized access.
Testing and activating
- Submit sample data through the form URL provided by the Form Trigger node.
- Check the created Google Docs in your Drive to confirm proper data replacement.
- Once confirmed, toggle the workflow from disabled to enabled to start running it automatically in production.
- Monitor runs and errors via the n8n dashboard logs.
For privacy and control, consider using self-host n8n to run the workflow on your own server.
Key Code Snippets Used
Format form data Code node
This code takes all submitted form data and turns them into an array of key-value pairs.
const data = [];
Object.keys($('Form').all().map((item) => {
Object.keys(item.json).map((bodyProperty) => {
data.push({
key: bodyProperty,
value: item.json[bodyProperty],
});
})
}));
return {
webhook_data: data,
pairedItem: 0,
};
Format form data to Google Docs API requests Code node
This code converts the key-values to the Google Docs API “replaceAllText” requests.
const result = [];
$('Format form data').all().map((item) => {
item.json.webhook_data.map((data) => {
if ("submittedAt" !== data.key && "formMode" !== data.key) {
result.push({
"replaceAllText": {
"containsText": {
"text": `{{${data.key}}}`,
"matchCase": true
},
"replaceText": `${data.value}`
},
});
}
});
})
return {
data: result,
pairedItem: 0,
};
Common Problems and How to Fix Them
Failed to copy Google Drive template file
Cause: Wrong template file ID or missing permissions.
Fix: Check the file ID in the Google Drive node and make sure the OAuth user can access the file with edit rights.
Google Docs API Unauthorized or Forbidden error
Cause: OAuth credentials expired or configured wrong.
Fix: Re-authenticate Google Docs OAuth credentials and confirm API is enabled.
Form data not replacing variables in Google Doc
Cause: Placeholder variables in template don’t match form field names exactly.
Fix: Ensure placeholders use double curly braces {{ }} and names match the form fields letter by letter.
Customization Ideas
- Add new form fields (like “email” or “address”) in the Form Trigger node and add matching placeholders in the Google Docs template.
- Change Google Docs template by replacing the template file ID in the Google Drive copy node.
- Protect the form by enabling Basic Authentication in the Form Trigger node settings.
- Adjust the copied file names by editing the expression in the Google Drive node’s Name field, adding timestamps or other details.
Summary
✓ Saves hours of manual copying by automating contract creation from forms.
✓ Eliminates errors from manual data entry, making contracts accurate every time.
✓ Quickly creates personalized Google Docs documents using form input.
✓ Works fully inside n8n using Google Drive and Google Docs API with simple setup.
✓ Suitable for event coordinators, businesses, anyone needing fast document prep from client data.

