{
  "name": "Automated sales proposal & summary generator using GPT-4o, Sheets, Drive & Gmail",
  "nodes": [
    {
      "id": "777285a5-1eef-449f-a871-d49ad20559ed",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -320,
        80
      ]
    },
    {
      "id": "c0b2ce0c-9203-4ebf-91b7-d653a32cda10",
      "name": "Retrieve Lead Records from Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -32,
        80
      ]
    },
    {
      "id": "96d9cd04-cbed-4b76-b834-cfd9879a50c4",
      "name": "Validate Lead Data Payload",
      "type": "n8n-nodes-base.if",
      "position": [
        224,
        80
      ]
    },
    {
      "id": "f62f1223-0844-4508-8890-81005623a89c",
      "name": "Log Invalid Leads to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        560,
        704
      ]
    },
    {
      "id": "8494847c-18f2-4acf-9df9-631cc6171385",
      "name": "Filter for Booked Leads",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        64
      ]
    },
    {
      "id": "aa70865b-a489-409b-a0f7-33c90c80be6d",
      "name": "Configure GPT-4o Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        1040,
        656
      ]
    },
    {
      "id": "03677f7a-0d0a-4cbc-9eef-90c3b152190c",
      "name": "Configure GPT-4o Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        2592,
        304
      ]
    },
    {
      "id": "f895ef8e-f5fe-42d7-aa1c-78048a47e31f",
      "name": "Generate Sales Collateral (AI)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        960,
        48
      ]
    },
    {
      "id": "a47f8735-b2e1-419f-8d0a-a19c7571c284",
      "name": "Parse AI JSON Output",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        48
      ]
    },
    {
      "id": "e9645b11-a174-4b8c-837a-965e96891ea5",
      "name": "Convert Collateral into Text Reports",
      "type": "n8n-nodes-base.code",
      "position": [
        1600,
        48
      ]
    },
    {
      "id": "883fc755-e17b-4b52-a0bf-dad261233226",
      "name": "Upload Sales Collateral to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1952,
        48
      ]
    },
    {
      "id": "7dc0e8b7-c4c0-402b-a07b-d08d17f0a310",
      "name": "Map Uploaded Files with Lead Data",
      "type": "n8n-nodes-base.code",
      "position": [
        2416,
        -560
      ]
    },
    {
      "id": "96bf790b-3c72-4b5b-a6fc-441f54190bb7",
      "name": "Update Lead Record with Proposal Link",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2848,
        -560
      ]
    },
    {
      "id": "c7cb7d0c-649b-42e9-9240-80a145ead27f",
      "name": "Generate Sales Summary Email",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2592,
        48
      ]
    },
    {
      "id": "2a05b783-c46f-4af6-ad3d-bfff4846f41d",
      "name": "Send Sales Summary Email via Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2992,
        48
      ]
    },
    {
      "id": "e38eb667-93f5-49c7-8339-587d80081bdb",
      "name": "Aggregate Uploaded File Metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        2320,
        48
      ]
    },
    {
      "id": "ff89bb1a-43f2-4818-9c2a-ae2380004c1d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -688
      ],
      "parameters": {
        "width": 736,
        "height": 528,
        "content": "## 🚀 Automated Sales Proposal & Summary Generator using GPT-4o, Sheets & Drive\nAutomatically generates personalized **Sales Collateral** (Summary, One-Pager, and Proposal) for each booked lead using G"
      }
    },
    {
      "id": "4938a972-69ef-482a-a151-3d240d1dbee0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -176
      ],
      "parameters": {
        "width": null,
        "height": 480,
        "content": "## 🧾 Retrieve Lead Records from Google Sheets  \nFetches lead data (Company Name, Email, Booking Status, etc.) from the  sheet.  \nActs as the workflow’s entry point.\n"
      }
    },
    {
      "id": "f2783d33-207f-45ba-badc-45a8504aa3ef",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -144
      ],
      "parameters": {
        "width": null,
        "height": 384,
        "content": "## 🧩 Validate Lead Data Payload  \nChecks if lead records have a valid email address.  \n✅ Valid → Sent for further processing  \n❌ Invalid → Logged in the “Invalid Leads” sheet.\n"
      }
    },
    {
      "id": "36fd3162-6f11-4eb5-ad6d-38ef92c4cdce",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        384
      ],
      "parameters": {
        "width": null,
        "height": 496,
        "content": "## ⚠️ Log Invalid Leads to Google Sheets  \nStores any malformed or missing lead entries for later cleanup.  \nPrevents workflow interruption due to bad data.\n"
      }
    },
    {
      "id": "6f580e0a-4ac0-4e11-a6ec-784e1ac12f89",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -160
      ],
      "parameters": {
        "width": null,
        "height": 416,
        "content": "## 🎯 Filter for Booked Leads  \nFilters only leads marked as “BOOKED”.  \nEnsures collateral generation only runs for confirmed clients.\n"
      }
    },
    {
      "id": "3e90c054-d86d-43a9-bc9a-7f8205cd180f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        400
      ],
      "parameters": {
        "width": null,
        "height": 416,
        "content": "## ⚙️ Configure GPT-4o Model  \nConnects Azure OpenAI GPT-4o for downstream nodes.  \nUsed for both sales collateral and HTML summary generation.\n"
      }
    },
    {
      "id": "b5d84a31-27ec-4e6d-8aad-c3b353528b99",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -224
      ],
      "parameters": {
        "width": 368,
        "height": 496,
        "content": "## 🧠 Generate Sales Collateral (AI)  \nGPT-4o generates 3 structured outputs per booked lead:\n1. **Sales Summary** — short overview  \n2. **One-Pager** — headline + 3 bullet points + CTA  \n3. **Proposal"
      }
    },
    {
      "id": "79046b82-31d1-4167-a3ca-c6b284414e1b",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        -224
      ],
      "parameters": {
        "width": 208,
        "height": 496,
        "content": "## 🧹 Parse AI JSON Output  \nCleans and parses the GPT-4o output into usable JSON keys:  \n- `summary`  \n- `one_pager`  \n- `proposal`  \nHandles invalid or raw responses safely.\n"
      }
    },
    {
      "id": "78156c47-0768-4e0c-9510-b8bc9484fa7b",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        -192
      ],
      "parameters": {
        "width": null,
        "height": 448,
        "content": "## 📄 Convert Collateral into Text Reports  \nConverts parsed AI output into `.txt` files using Node.js Buffer.  \nEach report contains Summary, One-Pager, and Proposal sections, formatted for readabilit"
      }
    },
    {
      "id": "04ac0c9f-379a-48a1-87db-53e617d46318",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        -240
      ],
      "parameters": {
        "width": null,
        "height": 528,
        "content": "## ☁️ Upload Sales Collateral to Google Drive  \nUploads each generated `.txt` collateral file to the “collatral data” folder.  \nReturns Google Drive view & download links for each file.\n"
      }
    },
    {
      "id": "7b809214-d5b2-4dd1-a78a-92b229118d98",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        -192
      ],
      "parameters": {
        "width": null,
        "height": 480,
        "content": "## 🗂️ Aggregate Uploaded File Metadata  \nBuilds an HTML-formatted list of all uploaded collateral files.  \nIncludes file names, links, and lead count for summary email generation.\n"
      }
    },
    {
      "id": "1add2ee3-c9a5-4ff0-9063-818d04019863",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        -864
      ],
      "parameters": {
        "width": null,
        "height": 512,
        "content": "## 🔗 Map Uploaded Files with Lead Data  \nMatches each uploaded file with its corresponding lead using index mapping.  \nPrepares structured data (Email, ProposalLink, FileName, etc.) for updating the s"
      }
    },
    {
      "id": "eaf359c6-89fb-4048-9daf-60de8aaf94c4",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2768,
        -816
      ],
      "parameters": {
        "width": null,
        "height": 448,
        "content": "## ✅ Update Lead Record with Proposal Link  \nUpdates each lead’s Google Sheet row with its proposal file link.  \nKeeps all generated collateral traceable directly from the CRM.\n"
      }
    },
    {
      "id": "f2049739-3eb0-4fcc-985c-653c637d4155",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2928,
        -224
      ],
      "parameters": {
        "width": null,
        "height": 480,
        "content": "## 📧 Send Sales Summary Email via Gmail  \nDelivers the AI-generated HTML report to the marketing/sales inbox.  \nSubject: “Sales Collateral Summary.”  \nAutomatically formatted for Gmail/Outlook renderi"
      }
    },
    {
      "id": "1cefbc60-68af-4210-89ee-c4192987b53b",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2528,
        -224
      ],
      "parameters": {
        "width": 320,
        "height": 688,
        "content": "## ✉️ Generate Sales Summary Email (AI)  \nUses GPT-4o to create a **HTML-formatted sales summary email** that includes:  \n- Total booked leads processed  \n- List of uploaded proposal files (with links"
      }
    }
  ],
  "connections": {
    "Parse AI JSON Output": {
      "main": [
        [
          {
            "node": "Convert Collateral into Text Reports",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Sales Collateral (AI)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Configure GPT-4o Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Sales Summary Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Filter for Booked Leads": {
      "main": [
        [
          {
            "node": "Generate Sales Collateral (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Lead Data Payload": {
      "main": [
        [
          {
            "node": "Filter for Booked Leads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Invalid Leads to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sales Summary Email": {
      "main": [
        [
          {
            "node": "Send Sales Summary Email via Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Sales Collateral (AI)": {
      "main": [
        [
          {
            "node": "Parse AI JSON Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Uploaded File Metadata": {
      "main": [
        [
          {
            "node": "Generate Sales Summary Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Uploaded Files with Lead Data": {
      "main": [
        [
          {
            "node": "Update Lead Record with Proposal Link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Collateral into Text Reports": {
      "main": [
        [
          {
            "node": "Upload Sales Collateral to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Retrieve Lead Records from Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Sales Collateral to Google Drive": {
      "main": [
        [
          {
            "node": "Aggregate Uploaded File Metadata",
            "type": "main",
            "index": 0
          },
          {
            "node": "Map Uploaded Files with Lead Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Lead Records from Google Sheets": {
      "main": [
        [
          {
            "node": "Validate Lead Data Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}