{
  "name": "Generate and send AI-powered sales quotes with Gmail, OpenAI and Supabase",
  "nodes": [
    {
      "id": "0c011a93-d7c4-4527-9312-37fdacfa7e50",
      "name": "📋 Workflow Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        8464,
        -944
      ],
      "parameters": {
        "width": 480,
        "height": 784,
        "content": "## 🎯 AI QUOTE SYSTEM - COMPLETE WORKFLOW\n\n**What This Workflow Does:**\n\n1. **Two Input Sources:**\n   - Gmail inbox monitoring (every 60 seconds)\n   - Website form submissions via webhook\n\n2. **AI Proc"
      }
    },
    {
      "id": "da3094f4-988c-450b-a024-c949138e5f9a",
      "name": "📧 Email Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9072,
        -928
      ],
      "parameters": {
        "width": 340,
        "height": 344,
        "content": "## 📧 EMAIL INPUT PATH\n\nMonitors Gmail inbox every 60 seconds.\n\n**Configuration:**\n- Poll interval: Every minute\n- Filters: INBOX label only\n- Format: Resolved (full content)\n\n**Output:**\n- Subject, bo"
      }
    },
    {
      "id": "722de022-9220-4276-adda-46ff47754cc2",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        9136,
        -544
      ]
    },
    {
      "id": "971916a3-2efa-46ce-be64-ee91f1bf952f",
      "name": "🌐 Form Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9072,
        -144
      ],
      "parameters": {
        "width": 340,
        "height": 380,
        "content": "## 🌐 WEBSITE FORM INPUT\n\nReceives form submissions from website.\n\n**Webhook URL:**\n`https://your-n8n.com/webhook/quote-request`\n\n**Expected Fields:**\n- name, email, phone\n- company\n- service_type\n- bu"
      }
    },
    {
      "id": "4f35b202-4986-4d5d-a75b-85dcaaf3e589",
      "name": "Webhook - Form Submission",
      "type": "n8n-nodes-base.webhook",
      "position": [
        9136,
        256
      ]
    },
    {
      "id": "79423dd1-8345-4ed4-b799-9c9c131d55d6",
      "name": "Respond - Form OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        9136,
        464
      ]
    },
    {
      "id": "c2dc102a-2bd0-432a-93f5-397c851a4554",
      "name": "🤖 AI Filter",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9568,
        -1008
      ],
      "parameters": {
        "width": 340,
        "height": 428,
        "content": "## 🤖 AI EMAIL FILTER\n\n**Purpose:** Determines if email is a quote request.\n\n**Filters OUT:**\n- Newsletters & marketing\n- Spam\n- Support tickets\n- Auto-replies\n- Calendar invites\n\n**Passes THROUGH:**\n-"
      }
    },
    {
      "id": "03c7fcea-18b0-4623-b7ec-a11703f9abaf",
      "name": "OpenAI - Email Filter",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        9616,
        -528
      ]
    },
    {
      "id": "bc328334-1c96-4f9b-82ba-b02044c80279",
      "name": "Parse Filter Response",
      "type": "n8n-nodes-base.code",
      "position": [
        9632,
        -320
      ]
    },
    {
      "id": "819f3511-6791-4f24-b6af-57c6a2139ea2",
      "name": "⚡ Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        10064,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 272,
        "content": "## ⚡ ROUTING DECISION\n\n**Email Path:**\nChecks if:\n- `is_quote_request = true`\n- `confidence >= 60`\n\n**YES** → Continue to extraction\n**NO** → Archive email\n\n**Saves API costs** by filtering spam"
      }
    },
    {
      "id": "2444b9ab-d015-431b-8be8-e66242688a8a",
      "name": "IF - Is Quote Request?",
      "type": "n8n-nodes-base.if",
      "position": [
        10144,
        -544
      ]
    },
    {
      "id": "296bddf1-0074-498a-837c-a7f33b9c7634",
      "name": "🔀 Merge Sources",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        10576,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 236,
        "content": "## 🔀 MERGE DATA SOURCES\n\nNormalizes data from both paths:\n- Email → AI filter output\n- Form → Webhook body\n\nAdds `source` field: 'email' or 'form'\n\nEnsures consistent structure."
      }
    },
    {
      "id": "c86dccf6-5726-4e31-a264-11e153d5fc73",
      "name": "Merge - Both Paths",
      "type": "n8n-nodes-base.merge",
      "position": [
        10624,
        -560
      ]
    },
    {
      "id": "57578f96-24af-4549-a083-22ad3a95e281",
      "name": "Normalize Data",
      "type": "n8n-nodes-base.code",
      "position": [
        10624,
        -320
      ]
    },
    {
      "id": "67a71f8d-5ff0-485d-890a-46b9d44fa4a3",
      "name": "🧠 Extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11072,
        -992
      ],
      "parameters": {
        "width": 380,
        "height": 396,
        "content": "## 🧠 AI EXTRACTION & CLASSIFICATION\n\n**Extracts:**\n- contact_name, company_name\n- email, phone\n- service_type (categorized)\n- budget_range, timeline\n- special_requirements\n- decision_maker (boolean)\n\n"
      }
    },
    {
      "id": "66615f59-9f19-4b2b-a975-01a831e22c49",
      "name": "OpenAI - Extract & Classify",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        11136,
        -544
      ]
    },
    {
      "id": "0e8e9507-2a40-4097-bf1b-5dd051a7d370",
      "name": "Parse Extraction",
      "type": "n8n-nodes-base.code",
      "position": [
        11216,
        -304
      ]
    },
    {
      "id": "2e48ad2c-9c04-41fe-8193-8cdf53926e7a",
      "name": "💾 Save Initial",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11568,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 268,
        "content": "## 💾 SAVE INITIAL RECORD\n\nCreates record in Supabase:\n- All extracted contact info\n- Classification scores\n- Status: 'PROCESSING'\n- Timestamp\n\nReturns record ID for updates."
      }
    },
    {
      "id": "3737ac06-8bb0-48d9-a743-e427ce7f2ea2",
      "name": "Prepare Insert",
      "type": "n8n-nodes-base.code",
      "position": [
        11632,
        -544
      ]
    },
    {
      "id": "c173a985-956a-486e-b00c-5a342081003c",
      "name": "Supabase - Save Initial",
      "type": "n8n-nodes-base.supabase",
      "position": [
        11632,
        -320
      ]
    },
    {
      "id": "f4df8101-1619-45e2-917d-41d01a6f38c7",
      "name": "📊 Historical",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        12048,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 360,
        "content": "## 📊 SEARCH SIMILAR QUOTES\n\n**Queries Supabase for:**\n- Same service_type\n- Status = 'WON'\n- Last 10 similar projects\n\n**Provides:**\n- Historical pricing data\n- Win rates\n- Scope comparisons\n\nImproves"
      }
    },
    {
      "id": "07e27243-c975-4df8-9902-56380742c834",
      "name": "Supabase - Search Similar",
      "type": "n8n-nodes-base.supabase",
      "position": [
        12128,
        -544
      ]
    },
    {
      "id": "7e1022f9-74cf-4971-a2a8-c172f7d8ab3f",
      "name": "💰 Pricing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        12576,
        -944
      ],
      "parameters": {
        "width": 360,
        "height": 368,
        "content": "## 💰 AI PRICING CALCULATION\n\n**Inputs:**\n- Current request details\n- Historical similar quotes\n- Business pricing rules\n\n**Calculates:**\n- good_price (basic)\n- better_price (standard)\n- best_price (pr"
      }
    },
    {
      "id": "5507604b-dca5-4202-8a87-d3ed4bc7ebea",
      "name": "OpenAI - Calculate Pricing",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        12624,
        -544
      ]
    },
    {
      "id": "2a11336b-eb07-42ff-b302-58dd54768dbe",
      "name": "Parse Pricing",
      "type": "n8n-nodes-base.code",
      "position": [
        12624,
        -320
      ]
    },
    {
      "id": "bd97ad96-b88b-47df-b953-180a3dd925bd",
      "name": "✉️ Draft Email",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13072,
        -944
      ],
      "parameters": {
        "width": 360,
        "height": 336,
        "content": "## ✉️ GENERATE DRAFT EMAIL\n\n**AI writes quote including:**\n- Professional greeting\n- Acknowledgment of needs\n- 3-tier pricing options\n- What's included per tier\n- Clear CTA\n- Professional signature\n\n*"
      }
    },
    {
      "id": "52beadb7-b2b8-47d4-a7af-d1eccb982c78",
      "name": "OpenAI - Generate Draft",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        13136,
        -544
      ]
    },
    {
      "id": "91811f78-e3f2-4156-ad0a-f731e407be08",
      "name": "Prepare Update",
      "type": "n8n-nodes-base.code",
      "position": [
        13136,
        -320
      ]
    },
    {
      "id": "b04bcea0-0bc2-4758-98a5-58f36101b57e",
      "name": "🔄 Update DB",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13568,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 292,
        "content": "## 🔄 UPDATE DATABASE\n\n**Adds to record:**\n- good_price\n- better_price\n- best_price\n- draft_email content\n- priority_score\n- Status: 'PENDING_REVIEW'\n\n**Now ready for:**\nHuman review in dashboard"
      }
    },
    {
      "id": "28d1e3a5-82a4-4819-a7b4-e94fcd510161",
      "name": "Supabase - Update Complete",
      "type": "n8n-nodes-base.supabase",
      "position": [
        13632,
        -544
      ]
    },
    {
      "id": "c5e81a95-b31a-46cf-b8b5-138bb4d94bee",
      "name": "🔔 Slack Alert",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        14064,
        -944
      ],
      "parameters": {
        "width": 340,
        "height": 332,
        "content": "## 🔔 SLACK NOTIFICATION\n\n**Triggers when:**\nvalue_estimate >= $10,000\n\n**Alert includes:**\n- Company name\n- Contact name\n- Estimated value\n- Service type\n- Urgency level\n- Dashboard link\n\n**Optional:*"
      }
    },
    {
      "id": "8594da05-9ee9-4100-aefd-227ad43550a1",
      "name": "IF - High Value?",
      "type": "n8n-nodes-base.if",
      "position": [
        14128,
        -544
      ]
    },
    {
      "id": "22ce20d4-d45d-4c10-97fe-f7a4fe180cf5",
      "name": "Slack - High Value Alert",
      "type": "n8n-nodes-base.slack",
      "position": [
        14128,
        -320
      ]
    },
    {
      "id": "8c2d5fca-0898-45ba-b909-246bebda356e",
      "name": "📤 Send Webhook",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        10464,
        976
      ],
      "parameters": {
        "width": 380,
        "height": 404,
        "content": "## 📤 SEND QUOTE WEBHOOK\n\n**Triggered by Replit** when user clicks\n'Approve & Send'\n\n**Receives:**\n- quote_id\n- recipient_email\n- company_name\n- service_type\n- final_email_body\n\n**Actions:**\n1. Send em"
      }
    },
    {
      "id": "e8e0812c-1835-43e3-8c37-75fa139f4d99",
      "name": "Webhook - Send Quote",
      "type": "n8n-nodes-base.webhook",
      "position": [
        10576,
        1424
      ]
    },
    {
      "id": "f1d4d017-4f4b-4180-aeb9-6e901a1fa7c1",
      "name": "Gmail - Send Quote",
      "type": "n8n-nodes-base.gmail",
      "position": [
        11072,
        1424
      ]
    },
    {
      "id": "9f2332b9-f09e-429a-8309-3e7975e28224",
      "name": "Set Sent Status",
      "type": "n8n-nodes-base.code",
      "position": [
        11568,
        1424
      ]
    },
    {
      "id": "5a3ee42b-d3dd-4f35-ac2a-9bfc8ac22605",
      "name": "Supabase - Mark Sent",
      "type": "n8n-nodes-base.supabase",
      "position": [
        12064,
        1424
      ]
    },
    {
      "id": "707851ff-ddf3-4884-9e95-a3347177ace3",
      "name": "Respond - Success",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        12576,
        1424
      ]
    },
    {
      "id": "6e01b961-8b7d-4a43-af9c-13c17e15b15d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9072,
        -352
      ],
      "parameters": {
        "width": 336,
        "height": 192,
        "content": "@[youtube](sAGuFV60Big)"
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "OpenAI - Email Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Pricing": {
      "main": [
        [
          {
            "node": "OpenAI - Generate Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Data": {
      "main": [
        [
          {
            "node": "OpenAI - Extract & Classify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Insert": {
      "main": [
        [
          {
            "node": "Supabase - Save Initial",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Update": {
      "main": [
        [
          {
            "node": "Supabase - Update Complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Sent Status": {
      "main": [
        [
          {
            "node": "Supabase - Mark Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - High Value?": {
      "main": [
        [
          {
            "node": "Slack - High Value Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Extraction": {
      "main": [
        [
          {
            "node": "Prepare Insert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Send Quote": {
      "main": [
        [
          {
            "node": "Set Sent Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge - Both Paths": {
      "main": [
        [
          {
            "node": "Normalize Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Mark Sent": {
      "main": [
        [
          {
            "node": "Respond - Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - Send Quote": {
      "main": [
        [
          {
            "node": "Gmail - Send Quote",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Email Filter": {
      "main": [
        [
          {
            "node": "Parse Filter Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Filter Response": {
      "main": [
        [
          {
            "node": "IF - Is Quote Request?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Is Quote Request?": {
      "main": [
        [
          {
            "node": "Merge - Both Paths",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "OpenAI - Generate Draft": {
      "main": [
        [
          {
            "node": "Prepare Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Save Initial": {
      "main": [
        [
          {
            "node": "Supabase - Search Similar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Search Similar": {
      "main": [
        [
          {
            "node": "OpenAI - Calculate Pricing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook - Form Submission": {
      "main": [
        [
          {
            "node": "Merge - Both Paths",
            "type": "main",
            "index": 1
          },
          {
            "node": "Respond - Form OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Calculate Pricing": {
      "main": [
        [
          {
            "node": "Parse Pricing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase - Update Complete": {
      "main": [
        [
          {
            "node": "IF - High Value?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI - Extract & Classify": {
      "main": [
        [
          {
            "node": "Parse Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}