{
  "name": "Create custom PDF documents from templates with Gemini & Google Drive",
  "nodes": [
    {
      "id": "d6dae967-cee4-4c8b-9f80-a1eb8279b2a0",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -20,
        300
      ]
    },
    {
      "id": "514e6233-fe2d-4031-9ea6-ad046d2d1479",
      "name": "GetMetaData",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        420,
        300
      ]
    },
    {
      "id": "c2d0ed01-0b5f-4e92-89a1-c140990b6998",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -60,
        -20
      ]
    },
    {
      "id": "74c575a0-6523-47d5-834e-a0c388d06676",
      "name": "DocAgent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        -20
      ]
    },
    {
      "id": "753c8e8c-18f3-4a54-80a5-af1b5256a656",
      "name": "DocProcess",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        600,
        300
      ]
    },
    {
      "id": "25b8e0ed-90ed-4e14-a042-a36a2cb6ec15",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        200,
        300
      ]
    },
    {
      "id": "806c4fa9-6276-4066-b2ca-f0432c4ef228",
      "name": "Template List",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -500,
        440
      ]
    },
    {
      "id": "5a5f198e-b611-492e-a194-0cdfc6d8a3de",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        260
      ],
      "parameters": {
        "width": 260,
        "height": 360,
        "content": "## Manual Template List Retrieval\n**The response returned from this API request is manually added to the system prompt.\n\n"
      }
    },
    {
      "id": "0ff8e732-1497-45af-b8a6-b29287d72f5f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        260
      ],
      "parameters": {
        "width": 180,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n**It is preferred for more consistent memory management. Other alternatives can also be tried."
      }
    },
    {
      "id": "656dedde-5074-412b-ab5b-d6ee9980d8d9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        260
      ],
      "parameters": {
        "width": 180,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n**Metadata of the template selected by the user is dynamically retrieved."
      }
    },
    {
      "id": "79633aef-0d8e-4f85-93f4-af4a13f47a7a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        260
      ],
      "parameters": {
        "width": 180,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n**Prioritized due to free API-Key trial."
      }
    },
    {
      "id": "839584c8-ce14-4c66-aee2-aa6572345fcc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        -60
      ],
      "parameters": {
        "width": 1280,
        "height": 4140,
        "content": "## Description  \n\n## 1 — What Does It Do / Which Problem Does It Solve?\n\nThis workflow turns Google Docs-based contract & form templates into **ready-to-sign PDFs in minutes**—all from a single chat f"
      }
    },
    {
      "id": "69000a74-eba7-41a8-8c93-635e8664a1ce",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        660
      ],
      "parameters": {
        "width": 3640,
        "height": 1040,
        "content": "## DocProcess (Subworkflow)"
      }
    },
    {
      "id": "d5f08f8a-d45c-4a6b-9223-b98aafe7b6a3",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        80,
        1020
      ]
    },
    {
      "id": "709b08c4-7c8c-4d63-a8c2-3e8d96df40ce",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        660,
        1020
      ]
    },
    {
      "id": "2dd91c47-fefb-4715-a3ce-4a9f411d569d",
      "name": "Google Gemini Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1620,
        1140
      ]
    },
    {
      "id": "eac6b3cd-eb34-476d-a500-71bce8d5c29a",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        440,
        1240
      ]
    },
    {
      "id": "76be9549-a482-496a-b11c-ddf8a958f39a",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1320,
        920
      ]
    },
    {
      "id": "011d9a1a-3841-4fbd-84f6-99b4ad4eb782",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        2340,
        920
      ]
    },
    {
      "id": "1f537d7f-d6d1-463b-999c-73fcba2b5024",
      "name": "Other Errors",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        1420
      ]
    },
    {
      "id": "b0790f5f-256e-4559-926d-9ab45f1cad96",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        3000,
        1120
      ]
    },
    {
      "id": "26c8978f-4f18-4026-994a-4c3b2b0dfeed",
      "name": "CopyTemplate",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2120,
        920
      ]
    },
    {
      "id": "9ff9e7e9-1455-4d0b-8191-79b0c74b363b",
      "name": "FillDocument",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2560,
        1020
      ]
    },
    {
      "id": "ce49d769-0a53-40d0-b05c-25b071994aff",
      "name": "Google Gemini Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        320,
        1240
      ]
    },
    {
      "id": "cec0fdb3-0d86-47d5-9393-7718f20c5cf1",
      "name": "User Choice Matching Error",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        1120
      ]
    },
    {
      "id": "bbb55fdb-6f7c-404c-8f00-c5d9da4e4803",
      "name": "User Choice Match Correct",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        920
      ]
    },
    {
      "id": "e47a0291-ffa1-4cf5-850d-f882849eb917",
      "name": "User Choice Match Check",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        300,
        1020
      ]
    },
    {
      "id": "6c13dece-f397-4d12-b60f-64890848889e",
      "name": "GetMetaData2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1100,
        920
      ]
    },
    {
      "id": "a9303653-7510-4fb7-b16c-14e49e7de89b",
      "name": "Format Control",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1540,
        920
      ]
    },
    {
      "id": "ad6cfa0a-d879-465c-8fec-26f3bc281f4c",
      "name": "Formatting Correction",
      "type": "n8n-nodes-base.code",
      "position": [
        1900,
        920
      ]
    },
    {
      "id": "faeaad9d-e23c-429b-bff9-bb277dcf677f",
      "name": "Cop. Document ID Matching Error",
      "type": "n8n-nodes-base.set",
      "position": [
        2560,
        820
      ]
    },
    {
      "id": "2dba1518-f4ce-4d85-95a3-40245b3226bc",
      "name": "if",
      "type": "n8n-nodes-base.if",
      "position": [
        2780,
        1020
      ]
    },
    {
      "id": "ca0de06e-d55a-4243-94ff-55cd742c28a8",
      "name": "Generate Download Link",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3000,
        820
      ]
    },
    {
      "id": "9deae9c7-8b62-475d-bff8-b04295df2e35",
      "name": "Download Link Format",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        820
      ]
    },
    {
      "id": "3a2bbdb7-a69c-4b5f-8050-b75cfaed6d2e",
      "name": "Incomplete Information Error",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        1020
      ]
    },
    {
      "id": "132e6eb0-6630-4cd2-b490-b5033bf1782a",
      "name": "Template Technical Error",
      "type": "n8n-nodes-base.set",
      "position": [
        3220,
        1220
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "User Choice Match Correct",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "User Choice Matching Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "if": {
      "main": [
        [
          {
            "node": "Generate Download Link",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Cop. Document ID Matching Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "FillDocument",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Template Technical Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Incomplete Information Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Other Errors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DocProcess": {
      "ai_tool": [
        [
          {
            "node": "DocAgent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Format Control",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetMetaData": {
      "ai_tool": [
        [
          {
            "node": "DocAgent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "CopyTemplate": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FillDocument": {
      "main": [
        [
          {
            "node": "if",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetMetaData2": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Control": {
      "main": [
        [
          {
            "node": "Formatting Correction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "DocAgent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Formatting Correction": {
      "main": [
        [
          {
            "node": "CopyTemplate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Download Link": {
      "main": [
        [
          {
            "node": "Download Link Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "User Choice Match Check": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "DocAgent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "User Choice Match Check",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Format Control",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "User Choice Match Check",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "User Choice Match Correct": {
      "main": [
        [
          {
            "node": "GetMetaData2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "DocAgent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "User Choice Match Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}