{
  "name": "Generate pro construction quotes from jotform to email with Supabase CRM",
  "nodes": [
    {
      "id": "91382688-a0fe-4742-8ef3-5ea6ae60cf7a",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2220,
        480
      ]
    },
    {
      "id": "e34d7b7d-2f72-4219-955f-0b9cf0f7767c",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        360,
        520
      ]
    },
    {
      "id": "79089f76-5979-40da-8413-294ab2c36a9f",
      "name": "upsert form submission -error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        -1500,
        340
      ]
    },
    {
      "id": "274e1421-0331-4c7b-9f12-18f56f7f693b",
      "name": "upsert form customer -error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        -760,
        720
      ]
    },
    {
      "id": "91a02c0c-0d25-461b-b4fd-b4bb4b383e73",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -3020,
        1120
      ]
    },
    {
      "id": "da86a862-9673-4403-a53d-2e11c76a92dc",
      "name": "Stage 1: Webhook Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1880,
        -320
      ],
      "parameters": {
        "width": 600,
        "height": 1220,
        "content": "## 📥 STAGE 1: Form Submission Processing\n\n**Flow:**\nWebhook → Parser → Fetch Mapping Rules → Normalize Form Data → Save Form Submission\n\n**What happens:**\n1. **Webhook** receives JotForm POST (trigger"
      }
    },
    {
      "id": "ea6aae0b-6f27-4163-9dd3-4e0fef2c70ed",
      "name": "Stage 2: CRM Insert",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -320
      ],
      "parameters": {
        "width": 600,
        "height": 680,
        "content": "## 👤 STAGE 2: Customer & Deal Creation\n\n**Flow:**\nNormalize Form Data → Upsert Customer → Create Deal → Fetch Pricing Rules\n\n**What happens:**\n1. **Upsert Customer** (idempotent on email):\n   - Stores"
      }
    },
    {
      "id": "45ce9276-6205-4082-87eb-ec4c2bd138a5",
      "name": "Stage 3: Quote Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -320
      ],
      "parameters": {
        "width": 1120,
        "height": 1160,
        "content": "## 💰 STAGE 3: Quote Calculation Engine\n\n**Flow:**\nCreate Deal → Fetch Pricing Rules → Calculate Quote Line Items → Save Estimate Header → Prepare Line Item Data → Split Out → Insert Line Items\n\n**What"
      }
    },
    {
      "id": "c1e7d64b-2d95-47c6-bb2b-893829df10ff",
      "name": "Parser",
      "type": "n8n-nodes-base.set",
      "position": [
        -2080,
        480
      ]
    },
    {
      "id": "d8f73def-48d3-4902-adac-27a72833342f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3140,
        620
      ],
      "parameters": {
        "width": 660,
        "height": 760,
        "content": "# 💡 Experience Our Quote System\n\n## Get Your Instant Quote\n**https://form.jotform.com/252844786304060**\n\n**See how fast it is:**\nDescribe your plastering project → Get detailed quote in under 1 minute"
      }
    },
    {
      "id": "c9bd65eb-077d-4121-abe8-ce951b488cd0",
      "name": "Save Form Submission",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1760,
        320
      ]
    },
    {
      "id": "03f3eb45-f8f1-4fc0-bb4e-d874d143519e",
      "name": "Upsert Customer",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1040,
        580
      ]
    },
    {
      "id": "83b46cfd-3d21-4a58-9919-216718375de1",
      "name": "Create Deal",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -760,
        460
      ]
    },
    {
      "id": "c1a98178-4a69-47ac-a8fe-b0d18ca45b49",
      "name": "Fetch Pricing Rules",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -340,
        520
      ]
    },
    {
      "id": "233eb854-f2ba-46dd-a041-a526ddd9b150",
      "name": "Calculate Quote Line Items",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        520
      ]
    },
    {
      "id": "056fd166-3e72-42aa-bcf7-53c2e3832566",
      "name": "Save Estimate Header",
      "type": "n8n-nodes-base.supabase",
      "position": [
        20,
        520
      ]
    },
    {
      "id": "71ab5d4a-fcdb-4c73-838e-cba1badde940",
      "name": "Insert Line Items",
      "type": "n8n-nodes-base.supabase",
      "position": [
        520,
        520
      ]
    },
    {
      "id": "ddfe1924-d3c7-4f59-b0dc-dd0a6ae22b0a",
      "name": "Prepare Line Item Data",
      "type": "n8n-nodes-base.set",
      "position": [
        200,
        520
      ]
    },
    {
      "id": "850a5d90-1799-4366-a035-3800704ebe9d",
      "name": "Fetch Complete Quote",
      "type": "n8n-nodes-base.supabase",
      "position": [
        960,
        200
      ]
    },
    {
      "id": "2d56a903-f00f-458b-a3cf-227fa4ab3f2b",
      "name": "Generate Email HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        1200,
        180
      ]
    },
    {
      "id": "e08e4103-f939-409d-8efc-74e700923700",
      "name": "Fetch Mapping Rules",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1800,
        680
      ]
    },
    {
      "id": "24829399-a739-47ac-8f49-ef0d69c58ad3",
      "name": "Prepare AI Context",
      "type": "n8n-nodes-base.set",
      "position": [
        -1620,
        680
      ]
    },
    {
      "id": "f75648b6-fc6b-490a-b675-f9f32a022e36",
      "name": "Normalize Form Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1440,
        680
      ]
    },
    {
      "id": "54e66e54-b426-4607-95d6-d72d7c4a129e",
      "name": "Stage 3: Quote Generation1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -580
      ],
      "parameters": {
        "width": 880,
        "height": 940,
        "content": "## 📧 STAGE 4: Professional Quote Email\n\n**Flow:**\nInsert Line Items → Fetch Complete Quote → Generate Email HTML → (Send Email - not shown)\n\n**What happens:**\n1. **Fetch Complete Quote** queries `v_es"
      }
    },
    {
      "id": "24fa29f7-0d5a-4426-94b4-7b65d7d57fbc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3160,
        -220
      ],
      "parameters": {
        "width": 900,
        "height": 540,
        "content": "## Automated Quote Generation System\n\n**What it does:**\nTransforms JotForm submissions into professional quotes with CRM integration and email delivery.\n\n**The problem it solves:**\nManual quote creati"
      }
    },
    {
      "id": "0d8541d8-5adf-440f-8f6e-e59cf4e728c9",
      "name": "Send Email node",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1460,
        180
      ]
    },
    {
      "id": "d9ce54c4-9beb-4565-a92a-ac5b5e9bf754",
      "name": "SQL Schema Generator",
      "type": "n8n-nodes-base.code",
      "position": [
        -2820,
        1120
      ]
    }
  ],
  "connections": {
    "Parser": {
      "main": [
        [
          {
            "node": "Fetch Mapping Rules",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save Form Submission",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Parser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Insert Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Deal": {
      "main": [
        [
          {
            "node": "Fetch Pricing Rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Customer": {
      "main": [
        [
          {
            "node": "Create Deal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "upsert form customer -error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Line Items": {
      "main": [
        [
          {
            "node": "Fetch Complete Quote",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare AI Context": {
      "main": [
        [
          {
            "node": "Normalize Form Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Mapping Rules": {
      "main": [
        [
          {
            "node": "Prepare AI Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Pricing Rules": {
      "main": [
        [
          {
            "node": "Calculate Quote Line Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Email HTML": {
      "main": [
        [
          {
            "node": "Send Email node",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Form Data": {
      "main": [
        [
          {
            "node": "Upsert Customer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Complete Quote": {
      "main": [
        [
          {
            "node": "Generate Email HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Estimate Header": {
      "main": [
        [
          {
            "node": "Prepare Line Item Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Form Submission": {
      "main": [
        [],
        [
          {
            "node": "upsert form submission -error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Line Item Data": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Quote Line Items": {
      "main": [
        [
          {
            "node": "Save Estimate Header",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "SQL Schema Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}