Create custom PDF documents from templates with Gemini & Google Drive
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (15)
- Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - Http Request Tool
n8n-nodes-base.httpRequestTool - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - Call n8n Workflow Tool
@n8n/n8n-nodes-langchain.toolWorkflow - Postgres Chat Memory
@n8n/n8n-nodes-langchain.memoryPostgresChat - HTTP Request
n8n-nodes-base.httpRequest - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - If
n8n-nodes-base.if - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Edit Fields (Set)
n8n-nodes-base.set - Switch
n8n-nodes-base.switch - Google Drive
n8n-nodes-base.googleDrive - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - Code
n8n-nodes-base.code
What it does
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. 1 — What Does It Do / Which Problem Does It Solve? This workflow turns Google Docs-based contract & form templates into ready-to-sign PDFs in minutes—all from a single chat flow. - Automates repetitive document creation. Instead of copying a rental, sales, or NDA template and filling it by hand every time, the bot asks for the required values and fills them in. - Eliminates human error. It lists every mandatory field so nothing is missed, and removes unnecessary clauses via conditional blocks. - Speeds up approvals. The final draft arrives as a direct PDF link—one click to send for signing. - One template → unlimited variations. Every new template you drop in Drive is auto-listed with zero workflow edits—it scales effortlessly. - 100 % no-code. Runs on n8n + Google Apps Script—no extra backend, self-hosted or cloud. --- 2 — How It Works (Detailed Flow) 1. 📝 Template Discovery 📂 The TemplateList node scans the Drive folder you specify via the ?mode=meta endpoint and returns an id / title / desc list. The bot shows this list in chat. 2. 🎯 Selection & Metadata Fetch The user types a template name. 🔍 GetMetaData opens the chosen Doc, extracts METAJSON, placeholders, and conditional blocks, then lists mandatory & optional fields. 3. 🗣 Data-Collection Loop - The bot asks for every placeholder value. - For each conditional block it asks 🟢 Yes / 🔴 No. Answers are accumulated in a data JSON object. 4. ✅ Final Confirmation The bot summarizes the inputs → when the user clicks Confirm, the DocProcess sub-workflow starts. 5. ⚙️ DocProcess Sub-Workflow | 🔧 Step | Node | Task | | --- | --- | --- | | 1 | User Choice Match Check | Verifies name–ID match; throws if wrong | | 2 | GetMetaData (renew) | Gets the latest placeholder list | | 3 | Validate JSON Format | Checks for missing / unknown fields | | 4 | CopyTemplate | Copies the Doc via Drive API | | 5 | FillDocument | Apps Script fills placeholders & removes blocks | | 6 | Generate PDF Link | Builds an export?format=pdf URL | 6. 📎 Delivery The master agent sends 🔗 Download PDF & ✏️ Open Google Doc links. 7. 🚫 Error Paths - status:"ERROR", missing:… → bot lists missing fields and re-asks. - unknown:… → template list is outdated; rerun TemplateList. - Any Apps Script error → the returned message is shown verbatim in chat. --- 3 — 🚀 Setup Steps (Full Checklist) > Goal: Get a flawless PDF on the first run. > > > Mentally tick the ☑️ in front of every line as you go. > ☁️ A. Google Drive Preparation | Step | Do This | Watch Out For | | --- | --- | --- | | 1 | Create a Templates/ folder → put every template Doc inside | Exactly one folder; no sub-folders | | 2 | Placeholders in every Doc are {{UPPERCASE}} | No Turkish chars or spaces | | 3 | Wrap optional clauses with BLOCKNAME:START…BLOCKNAME:END | The START tag must have a blank line above | | 4 | Add a METAJSON block at the very end | Script deletes it automatically after fill | | 5 | Right-click Doc > Details ▸ Description = 1-line human description | Shown by the bot in the list | | 6 | Create a second Generated/ folder (for copies) | Keeps Drive tidy | > 🔑 Folder ID (long alphanumerical) = <TEMPLATEPARENTID> > > > We’ll paste this into the TemplateList node next. > Simple sample template → Template Link --- 🛠 B. Import the Workflow into n8n bash Settings ▸ Import Workflow ▸ DocAgent.json If nodes look Broken afterwards → no community-node problem; you only need to select credentials. --- 📑 C. Customize the TemplateList Node 1. Open Template List node ⚙️ → replace '%3CYOURPARENTID%3E' in parents with the real folder ID in the URL. 2. Right-click node > Execute Node. 3. Copy the entire JSON response. 4. In the editor paste it into: - DocAgent → System Prompt (top) - User Choice Match Check → System Prompt (top) Save. > ⚠️ Why manual? Caching the list saves LLM tokens. Whenever you add