{
  "name": "AI Lead Enrichment & Outreach",
  "nodes": [
    {
      "id": "9d4e7f55-b1b1-4b1b-9b1b-000000000001",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "formTitle": "AI Lead Enrichment",
        "formDescription": "Drop a lead's email + website, describe what you sell, and get a scored lead plus a ready-to-send personalized email.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Lead Email",
              "fieldType": "email",
              "requiredField": true,
              "placeholder": "jane@acme.com"
            },
            {
              "fieldLabel": "Company Website",
              "fieldType": "text",
              "requiredField": true,
              "placeholder": "https://acme.com"
            },
            {
              "fieldLabel": "Lead Title",
              "fieldType": "text",
              "requiredField": false,
              "placeholder": "VP Engineering"
            },
            {
              "fieldLabel": "What You Sell",
              "fieldType": "textarea",
              "requiredField": true,
              "placeholder": "One paragraph: what your product does, ideal customer, pricing model, proof points."
            },
            {
              "fieldLabel": "Tone",
              "fieldType": "dropdown",
              "requiredField": true,
              "fieldOptions": {
                "values": [
                  {
                    "option": "Direct / B2B"
                  },
                  {
                    "option": "Warm / founder-to-founder"
                  },
                  {
                    "option": "Consultative / research-led"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "webhookId": "lead-enrich-form"
    },
    {
      "id": "9d4e7f55-b2b2-4b2b-9b2b-000000000002",
      "name": "Fetch Company Site",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        232,
        0
      ],
      "parameters": {
        "url": "={{ $json['Company Website'] }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text",
              "neverError": true
            }
          },
          "timeout": 15000,
          "redirect": {
            "redirect": {
              "followRedirects": true
            }
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (compatible; n8n-lead-enrichment/1.0)"
            }
          ]
        }
      }
    },
    {
      "id": "9d4e7f55-b3b3-4b3b-9b3b-000000000003",
      "name": "Extract Company Signals",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        472,
        0
      ],
      "parameters": {
        "jsCode": "const html = $input.first().json.data || $input.first().json.body || '';\nconst form = $('On form submission').item.json;\nconst leadEmail = form['Lead Email'];\nconst leadDomain = leadEmail.split('@')[1] || '';\n\nconst pick = (re) => { const m = html.match(re); return m ? m[1].trim() : ''; };\nconst title = pick(/<title[^>]*>([^<]+)<\\/title>/i);\nconst ogTitle = pick(/<meta[^>]+property=[\"']og:title[\"'][^>]+content=[\"']([^\"']+)[\"']/i);\nconst description = pick(/<meta[^>]+name=[\"']description[\"'][^>]+content=[\"']([^\"']+)[\"']/i);\nconst ogDesc = pick(/<meta[^>]+property=[\"']og:description[\"'][^>]+content=[\"']([^\"']+)[\"']/i);\n\n// Rough tech stack sniff\nconst stack = [];\nif (/next\\.js|__NEXT_DATA__|_next\\//i.test(html)) stack.push('Next.js');\nif (/react/i.test(html)) stack.push('React');\nif (/vue|vuejs|__VUE__/i.test(html)) stack.push('Vue');\nif (/shopify/i.test(html)) stack.push('Shopify');\nif (/wordpress|wp-content/i.test(html)) stack.push('WordPress');\nif (/hubspot/i.test(html)) stack.push('HubSpot');\nif (/intercom/i.test(html)) stack.push('Intercom');\nif (/segment|analytics\\.js/i.test(html)) stack.push('Segment');\nif (/cloudflare/i.test(html)) stack.push('Cloudflare');\n\n// Heuristic content signals (hiring, pricing, openai etc.)\nconst signals = [];\nif (/careers|we'?re hiring|open positions/i.test(html)) signals.push('Hiring');\nif (/pricing|plans|per month|\\$\\d+/i.test(html)) signals.push('Published pricing');\nif (/soc\\s*2|gdpr|hipaa|iso 27001/i.test(html)) signals.push('Mentions security compliance');\nif (/openai|gpt-|anthropic|claude|langchain/i.test(html)) signals.push('Builds on LLMs');\nif (/series [a-c]|raised|funding/i.test(html)) signals.push('Funding signals');\nif (/ycombinator|y combinator/i.test(html)) signals.push('YC-backed');\n\n// Clean body snippet for the AI\nconst body = html\n  .replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, ' ')\n  .replace(/<style[^>]*>[\\s\\S]*?<\\/style>/gi, ' ')\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .slice(0, 3500);\n\nreturn [{ json: {\n  leadEmail,\n  leadDomain,\n  leadTitle: form['Lead Title'] || '',\n  website: form['Company Website'],\n  whatYouSell: form['What You Sell'],\n  tone: form['Tone'],\n  companyTitle: ogTitle || title || 'Unknown',\n  companyDescription: ogDesc || description || '',\n  stack,\n  signals,\n  body\n}}];"
      }
    },
    {
      "id": "9d4e7f55-b4b4-4b4b-9b4b-000000000004",
      "name": "Qualify & Draft Email",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.5,
      "position": [
        712,
        0
      ],
      "parameters": {
        "promptType": "define",
        "text": "=You are a senior B2B sales engineer. Assess the lead and produce a structured qualification + cold email.\n\nLEAD\n- Email: {{ $json.leadEmail }}\n- Title: {{ $json.leadTitle || 'unknown' }}\n- Domain: {{ $json.leadDomain }}\n\nCOMPANY (from their site)\n- Name/Title: {{ $json.companyTitle }}\n- Description: {{ $json.companyDescription }}\n- Tech stack detected: {{ $json.stack.join(', ') || 'none detected' }}\n- Signals: {{ $json.signals.join(', ') || 'none' }}\n- Website snippet: \"\"\"{{ $json.body }}\"\"\"\n\nMY PRODUCT (what I sell):\n\"\"\"{{ $json.whatYouSell }}\"\"\"\n\nTONE: {{ $json.tone }}\n\nRULES\n- Score fit on a 0-100 scale. Be honest \u2014 if there's no fit, say so.\n- Cite 2-3 concrete reasons from the site or signals (not generic \"modern tech company\" fluff).\n- Email must mention at least one specific thing from their site (a product line, a tech choice, a hiring move, a customer).\n- Email subject \u2264 55 chars, no clickbait, no emojis, no \"Quick question\".\n- Email body \u2264 110 words. 3 short paragraphs. End with a low-friction CTA (15-minute chat, not a demo).\n- Skip the pleasantries. Do not open with \"Hope this finds you well.\"\n\nReturn strict JSON, nothing else:\n{\n  \"fit_score\": 0-100,\n  \"fit_reasons\": [\"reason 1\", \"reason 2\", \"reason 3\"],\n  \"disqualifiers\": [\"...\"] ,\n  \"email_subject\": \"...\",\n  \"email_body\": \"...\",\n  \"follow_up_angle\": \"One-sentence angle for a day-4 follow-up if no reply.\"\n}",
        "messages": {
          "messageValues": []
        },
        "batching": {},
        "hasOutputParser": true
      }
    },
    {
      "id": "9d4e7f55-b5b5-4b5b-9b5b-000000000005",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        648,
        224
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini"
        },
        "options": {}
      }
    },
    {
      "id": "9d4e7f55-b6b6-4b6b-9b6b-000000000006",
      "name": "Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        800,
        224
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"fit_score\": 0,\n  \"fit_reasons\": [\"string\"],\n  \"disqualifiers\": [\"string\"],\n  \"email_subject\": \"string\",\n  \"email_body\": \"string\",\n  \"follow_up_angle\": \"string\"\n}"
      }
    }
  ],
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Fetch Company Site",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Company Site": {
      "main": [
        [
          {
            "node": "Extract Company Signals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Company Signals": {
      "main": [
        [
          {
            "node": "Qualify & Draft Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Qualify & Draft Email",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Qualify & Draft Email",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null
}