{
  "id": "QuqGnjiFK087fVXK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Business Analysis Lead Magnet \u2013 Auto Email Report",
  "tags": [
    {
      "id": "NBUkGWImkiCq2Fgt",
      "name": "Captaci\u00f3n de Leads",
      "createdAt": "2025-07-27T09:58:14.293Z",
      "updatedAt": "2025-07-27T09:58:14.293Z"
    }
  ],
  "nodes": [
    {
      "id": "df8d781a-3c33-4f9f-adb0-a245c980e4e2",
      "name": "Form Trigger",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -672,
        272
      ],
      "parameters": {
        "options": {},
        "formTitle": "Free AI Business Audit",
        "formFields": {
          "values": [
            {
              "fieldType": "email",
              "fieldLabel": "email",
              "placeholder": "your@email.com",
              "requiredField": true
            },
            {
              "fieldLabel": "website",
              "placeholder": "https://yourwebsite.com",
              "requiredField": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6f5aa717-c655-4228-95cc-ba0d4815c254",
      "name": "OpenAI \u2013 Analyst Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        48,
        480
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.2",
          "cachedResultName": "gpt-5.2"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "abbcf3e0-195b-449a-95e3-5f235cb5cf90",
      "name": "Analyst Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        320,
        480
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"diagnostic\": {\n    \"business_type\": \"string\",\n    \"offers\": [\"string\"],\n    \"audience\": \"string\",\n    \"contact_channels\": [\"email\",\"form\"],\n    \"funnels\": [\"string\"],\n    \"pain_points\": [\n      {\"name\":\"string\",\"evidence\":\"string\",\"likelihood\":0.8}\n    ],\n    \"meta\": {\n      \"url\": \"https://example.com\",\n      \"page_title\": \"string\",\n      \"lang_detected\": \"en\",\n      \"content_quality\": {\"length_chars\": 12345, \"readability\": \"medium\"},\n      \"confidence_overall\": 0.8\n    }\n  },\n  \"copy_kit\": {\n    \"compliments\": [\"string\"],\n    \"hook_angles\": [\"string\"],\n    \"tone_mirror\": { \"traits\": [\"string\"], \"brand_words\": [\"string\"] },\n    \"objections\": [{\"objection\":\"string\",\"rebuttal\":\"string\"}],\n    \"cta_inventory\": {\n      \"existing\": [{\"label\":\"string\",\"url\":\"https://...\"}],\n      \"recommended\": [{\"label\":\"string\",\"why\":\"string\"}]\n    },\n    \"audience_jtbd\": [\n      {\"segment\":\"string\",\"job_to_be_done\":\"string\",\"fear\":\"string\",\"hope\":\"string\"}\n    ],\n    \"improvement_candidates\": [\n      {\"title\":\"string\",\"narrative\":\"string\",\"evidence_snippet\":\"string\",\"priority_score\":0.9}\n    ]\n  }\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "68c41d3b-921f-4df5-a1de-682d8da7e919",
      "name": "Writer Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        832,
        480
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"subject\": \"Your website analysis: 10 improvements to scale your business\",\n  \"preheader\": \"Genuine praise + 10 concrete improvements + call booking button\",\n  \"message_html\": \"<div style=\\\"font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;line-height:1.55;color:#111;\\\"><p>Hi John,</p><p><strong>Congratulations:</strong> your website conveys calm and professionalism; the value proposition is clear and approachable. Real experience guiding personal and team processes clearly shows.</p><p>With that foundation, your business has strong potential to scale by applying a few functional adjustments that reduce friction and give you time back.</p><p>I have analysed your website and propose <strong>10 improvements</strong> with direct impact:</p><ol><li>Change the main CTA from 'Contact' to 'Book a session' with an integrated calendar. Convert intent into an appointment without intermediate forms.</li></ol></div>\"\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "30df5820-1436-432f-a53f-b32c1f1b5e06",
      "name": "Analyst Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        112,
        272
      ],
      "parameters": {
        "text": "=Analyse this information and return the diagnostic JSON following the given schema:\n\n{\n  \"url\": \"{{ $json.url }}\",\n  \"page_title\": \"{{ $json.pageTitle }}\",\n  \"text\": \"{{ $json.text }}\",\n  \"signals\": {{ JSON.stringify($json.signals) }}\n}\n",
        "options": {
          "systemMessage": "You are \"AutoOps-DX\", a senior automation analyst for SMBs, coaches, info-product creators and online businesses. Your mission is to READ the content of a website (plain text derived from HTML) and return an actionable DIAGNOSTIC in STRICT JSON that identifies: business type, offers, contact channels, funnels and automatable PAIN POINTS.\n\n=== OPERATING PRINCIPLES ===\n1) Zero fluff, maximum practical precision. No empty marketing language.\n2) Evidence-based: anchor every conclusion to signals in the text. If inferring, mark low probability.\n3) Output EXCLUSIVELY valid JSON (no comments, no markdown, no additional text).\n4) Clear and concise language. Short names, business-oriented.\n5) Do not invent internal technology or unobservable metrics. Do not use sensitive data.\n6) If text is poor/noisy, lower confidence and explain the limitation in `meta.flags`.\n\n=== NORMALISATION AND HEURISTICS ===\n- Detect \"business_type\" by patterns:\n  * \"menu\", \"table booking\", \"reservation\" \u2192 restaurant.\n  * \"patients\", \"appointments\", \"clinic\", \"treatments\" \u2192 clinic/practice.\n  * \"cart\", \"checkout\", \"SKU\", \"shop\" \u2192 e-commerce.\n  * \"services\", \"portfolio\", \"agency\", \"consultancy\" \u2192 professional services/agency.\n  * \"plans\", \"pricing\", \"sign in\", \"demo\" \u2192 SaaS/B2B.\n  * \"classes\", \"course\", \"training\", \"academy\" \u2192 education/info-product.\n- `contact_channels` (list, lowercase, no duplicates), choose from:\n  [\"whatsapp\",\"phone\",\"email\",\"form\",\"booking\",\"shop\",\"chat\",\"social\",\"other\"].\n  Detection signals:\n    - whatsapp: \"wa.me\", \"api.whatsapp.com\", WhatsApp icon/CTA.\n    - phone: \"tel:\", numbers with country code, \"call us\".\n    - email: \"mailto:\", \"info@\u2026\", form with explicit email field.\n    - form: \"contact\", \"request information\", \"send enquiry\".\n    - booking: \"book\", \"appointment\", \"book now\", \"schedule\".\n    - shop: \"cart\", \"add to cart\", \"shop\", \"checkout\".\n    - chat: \"chat\", \"live chat\", \"intercom\", \"tawk\", \"zendesk chat\".\n    - social: links/icons to IG/FB/LinkedIn/TikTok as primary channel.\n- `funnels`: summarise in 1\u20132 simple strings (e.g. \"Discover \u2192 Visit site \u2192 Lead/Book \u2192 Purchase/Service\").\n- `pain_points`: 5\u201310 elements oriented to automation or business strategy improvement (operational, acquisition or management).\n  * Typical examples: no-shows, manual lead qualification, slow WhatsApp/IG response, appointment reminders, unconfirmed orders, repetitive FAQs, manual invoice management, post-sale follow-up, cart abandonment, lack of scoring, manual reporting.\n  * `likelihood`: 0.2 (low), 0.5 (medium), 0.8 (high), 1.0 (very high).\n  * `evidence`: short quote or \"weak signal: \u2026\" if no literal match.\n\n=== CONFIDENCE CALIBRATION ===\n- `meta.confidence_overall` (0\u20131) based on:\n  * +0.25 if text clearly identifies business type and offers.\n  * +0.25 if \u22652 contact channels detected.\n  * +0.25 if \u22653 pain points identified with evidence.\n  * +0.25 if funnel signals present (pricing/booking/checkout/demo).\n  Adjust down for: thin content, cookie wall, confusing multilingual, heavy JS with no content.\n  Clamp 0\u20131.\n\n=== OUTPUT RESTRICTIONS ===\n- STRICT JSON with ALL schema keys (no null values; use \"\" or [] where applicable).\n- Include no text outside the JSON.\n- Reasonable length: `offers` max 10; `pain_points` 7\u201310; `funnels` 1\u20132.\n\n=== MANDATORY SCHEMA ===\n{\n  \"diagnostic\": {\n    \"business_type\": \"string\",\n    \"offers\": [\"string\"],\n    \"audience\": \"string\",\n    \"contact_channels\": [\"whatsapp\",\"phone\",\"email\",\"form\",\"booking\",\"shop\",\"chat\",\"social\",\"other\"],\n    \"funnels\": [\"string\"],\n    \"pain_points\": [\n      {\"name\":\"string\",\"evidence\":\"string\",\"likelihood\":0.0}\n    ],\n    \"meta\": {\n      \"url\":\"string\",\n      \"page_title\":\"string\",\n      \"lang_detected\":\"string\",\n      \"content_quality\": {\"length_chars\":0,\"readability\":\"low|medium|high\"},\n      \"confidence_overall\":0.0\n    }\n  },\n  \"copy_kit\": {\n    \"compliments\": [\"string\"],\n    \"hook_angles\": [\"string\"],\n    \"tone_mirror\": {\n      \"traits\": [\"string\"],\n      \"brand_words\": [\"string\"]\n    },\n    \"objections\": [\n      {\"objection\":\"string\",\"rebuttal\":\"string\"}\n    ],\n    \"cta_inventory\": {\n      \"existing\": [{\"label\":\"string\",\"url\":\"string\"}],\n      \"recommended\": [{\"label\":\"string\",\"why\":\"string\"}]\n    },\n    \"audience_jtbd\": [\n      {\"segment\":\"string\",\"job_to_be_done\":\"string\",\"fear\":\"string\",\"hope\":\"string\"}\n    ],\n    \"improvement_candidates\": [\n      {\n        \"title\":\"string\",\n        \"narrative\": \"2\u20133 prose sentences; what to change and how to implement it\",\n        \"evidence_snippet\":\"string\",\n        \"priority_score\": 0.0\n      }\n    ]\n  }\n}\n\n=== INTERNAL POST-PROCESSING (DO THIS YOURSELF) ===\n- `lang_detected`: infer from predominant text language (\"es\", \"en\", \"pt\", etc.).\n- `content_quality.length_chars`: length of analysed text (approx).\n- `content_quality.readability`: estimate by complexity and noise (low/medium/high).\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "ea22a01b-6ad2-4c2e-b59a-a16d88277397",
      "name": "Writer Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        656,
        272
      ],
      "parameters": {
        "text": "=Write the email for this diagnostic:\n{{ JSON.stringify($json.output) }}\n\nOptional parameters:\n{\n  \"channel\": \"email\",\n  \"length\": \"standard\",\n  \"style\": \"direct\",\n  \"language\": \"{{ $json.output.diagnostic.meta.lang_detected || 'en' }}\"\n}",
        "options": {
          "systemMessage": "You are \"AutoOps-Writer\", a senior copywriter focused on selling AI automation services to SMBs.\nYour mission: convert the DIAGNOSTIC_JSON + COPY_KIT from the analyst agent into a commercial message that:\n1) Opens with a genuine compliment (from compliments) and explains the business has strong potential to scale with a few improvements.\n2) Describes EXACTLY 10 numbered improvements, written in natural prose (2\u20134 sentences each), linking each pain point to its concrete solution.\n3) Closes by inviting the reader to book a call to review their case and discuss a proposal.\n\n=== INPUTS ===\nYou will receive:\n- DIAGNOSTIC_JSON: { business_type, offers, audience, contact_channels, funnels, pain_points[{name,evidence,likelihood}], meta{url,page_title,lang_detected,content_quality,confidence_overall} }\n- COPY_KIT: {\n    compliments[], hook_angles[], tone_mirror{traits[],brand_words[]},\n    objections[{objection,rebuttal}], cta_inventory{existing[],recommended[]},\n    audience_jtbd[], improvement_candidates[{title,narrative,evidence_snippet,priority_score}]\n  }\n- Optional PARAMS:\n  { language, style }\n  Defaults: language = DIAGNOSTIC_JSON.meta.lang_detected || \"en\"; style = \"direct\".\n\n\u26a0\ufe0f CRITICAL: Write the entire email in the language indicated by `lang_detected`. If lang_detected is \"es\", write in Spanish. If \"en\", write in English. Always match the lead's language.\n\n=== MESSAGE STRUCTURE (MANDATORY) ===\n- Intro (compliment): use 1\u20132 phrases from COPY_KIT.compliments (not generic; adapt the tone) and acknowledge the scaling potential.\n- \"I analysed your business\u2026\" and introduce 10 numbered improvements (1\u201310). For each improvement:\n  \u2022 Write in prose (no telegraphic headlines).\n  \u2022 Explain WHAT can be changed, HOW it can be done, and why it improves conversion/operations.\n  \u2022 Anchor where appropriate with a micro-evidence (COPY_KIT.improvement_candidates[].evidence_snippet or pain_points[].evidence) in quotes.\n  \u2022 Selection: take the 10 with the highest priority_score from improvement_candidates. If any are missing, complete with highest-likelihood pain_points.\n- Close: Tell them you see clear growth potential and invite them to \"book a call\" to review their case and prepare a proposal.\n\n=== STYLE AND TONE ===\n- Professional, direct and encouraging. Zero fluff, zero unnecessary jargon.\n- Benefits > processes. Maintain the brand voice by reflecting tone_mirror.traits and using some brand_words where they fit naturally.\n- If confidence_overall < 0.6, soften assertions (\"likely\", \"appears to\") without losing clarity.\n- Do not invent figures. If estimating, mark as \"estimate\".\n- Keep the message concise. State the improvement, the pain point it solves, and move on. Maximum 30 words per paragraph.\n\n=== OUTPUT (STRICT JSON) ===\nReturn ONLY this object:\n{\n  \"subject\": \"string\",\n  \"preheader\": \"string\",\n  \"message_html\": \"string\"    // HTML version with <ol> for the 10 improvements\n}\n\n=== HTML FORMAT (recommended) ===\n- Container <div> with safe font-stack and line-height 1.55.\n- Intro and potential paragraph in <p>.\n- Improvements block in <ol><li>\u2026</li></ol> where each <li> contains a <p> in bold with the title and a <p> block with the improvement text.\n\n=== PROCEDURE ===\n1) Choose 1\u20132 compliments from COPY_KIT and write the intro explaining the potential.\n2) Select the 10 improvements from improvement_candidates by priority_score and convert to numbered prose; if any are missing, use highest-likelihood pain_points.\n3) Close with a clear invitation to book a call.\n\n=== PROHIBITIONS ===\n- No P.S.\n- No markdown in message fields.\n- No text outside the JSON.\n- No inline CSS annotations. Do not wrap everything in a single DIV; start directly with the first element and no element should have any style. Everything must be plain.\n- No buttons.\n- Do not mention the meeting duration or any plan to apply. Simply offer the possibility of booking a call.\n- Do not close with any signature.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "b050b9f3-db41-43a8-8178-350a68af86ae",
      "name": "OpenAI \u2013 Writer Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        576,
        464
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "667a3e94-1274-4de1-88c8-c4ad41910db9",
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1664,
        272
      ],
      "parameters": {
        "sendTo": "={{ $('Form Trigger').item.json.email }}",
        "message": "={{ $json.email_html }}",
        "options": {
          "senderName": "Stefan Joulien \u2013 Synecta",
          "appendAttribution": false
        },
        "subject": "=\ud83d\udd75\ud83c\udffb\u200d\u2642\ufe0f {{ $('Writer Agent').item.json.output.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "31b4b7f1-fcf3-4ca1-867a-4ed6cb81465a",
      "name": "Build Email HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        1216,
        272
      ],
      "parameters": {
        "jsCode": "// ============================================================\n// BUILD EMAIL HTML \u2014 Synecta-branded template\n// ============================================================\n// \u2699\ufe0f  CONFIGURE THESE VALUES BEFORE USING:\nconst YOUR_NAME        = 'Stefan Joulien \u2013 Synecta';          // \u2699\ufe0f Change to your name\nconst YOUR_EMAIL       = 'user@example.com';                 // \u2699\ufe0f Change to your email\nconst CAL_URL          = 'https://cal.eu/stefan-joulien-synecta/discovery'; // \u2699\ufe0f Change to your booking link\nconst INSTAGRAM_URL    = 'https://www.instagram.com/stefanjd.fit/';         // \u2699\ufe0f Change to your Instagram\nconst LINKEDIN_URL     = 'https://www.linkedin.com/in/stefan-joulien-ditchev/'; // \u2699\ufe0f Change to your LinkedIn\nconst LOGO_URL         = 'https://res.cloudinary.com/dmdmat24m/image/upload/v1773779124/Synecta_Logo_Horizontal_Alargado_v1sw74.png'; // \u2699\ufe0f Change to your logo URL\n// ============================================================\n\nconst RAW = ($input.first().json.output && $input.first().json.output.message_html) || '';\n\n// --- Synecta Brand Tokens ---\nconst C_PRIMARY   = '#6C63FF';   // Synecta violet\nconst C_DARK_BLUE = '#1C5D99';   // Synecta dark blue\nconst C_LIGHT     = '#AEB8FE';   // Synecta light violet\nconst C_BG        = '#F5F7FA';   // Off-white background\nconst C_DARK_BG   = '#1A1A1A';   // Footer dark\nconst FONT        = \"'Segoe UI', Tahoma, Geneva, Verdana, sans-serif\";\n\n// CTA button: gradient from violet to dark blue\nconst CTA_INLINE =\n  `display:inline-block;` +\n  `background:linear-gradient(90deg, ${C_PRIMARY} 0%, ${C_DARK_BLUE} 100%);` +\n  `color:#fff;text-decoration:none;padding:16px 40px;border-radius:14px;` +\n  `font-weight:700;font-size:15px;box-shadow:0 10px 30px rgba(108,99,255,0.35);` +\n  `text-align:center;min-width:220px;letter-spacing:.5px;text-transform:uppercase;`;\n\n// Avoid reprocessing\nif (/<!--SYNECTA-CARDS-->/i.test(RAW)) {\n  return [{ email_html: RAW }];\n}\n\n// 1) Strip any inline styles on <a> tags, reapply brand colour\nlet src = RAW.replace(/<a\\b([^>]*?)style=\"[^\"]*?\"([^>]*)>/gi, '<a $1$2>');\nsrc = src.replace(/<a\\b([^>]*)>/gi,\n  `<a $1 style=\"color:${C_PRIMARY};text-decoration:underline;text-underline-offset:2px;\">`\n);\n\n// 2) Convert <ol><li> into numbered card layout\nlet idx = 1;\nfunction liToCard(n, innerHtml) {\n  const m = innerHtml.match(/<p[^>]*>\\s*<strong>([\\s\\S]*?)<\\/strong>\\s*<\\/p>/i);\n  const title = (m ? m[1] : `Improvement ${n}`).trim();\n  const body  = (m ? innerHtml.replace(m[0], '') : innerHtml).trim();\n  return `\n  <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse:separate;margin:0 0 12px 0;\">\n    <tr>\n      <td style=\"background:#EEF0FF;border:1px solid ${C_LIGHT};border-radius:14px;padding:16px;\">\n        <table role=\"presentation\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n          <tr>\n            <td valign=\"top\" width=\"44\" style=\"width:44px;\">\n              <div style=\"width:34px;height:34px;border-radius:10px;\n                          background:linear-gradient(135deg,${C_PRIMARY},${C_DARK_BLUE});\n                          color:#fff;font-weight:800;font-size:14px;line-height:34px;\n                          text-align:center;font-family:${FONT};\n                          box-shadow:0 4px 12px rgba(108,99,255,0.4);\">\n                ${n}\n              </div>\n            </td>\n            <td style=\"padding-left:10px;\">\n              <div style=\"font-weight:800;font-size:15px;color:#1A1A1A;margin:0 0 5px 0;font-family:${FONT};\">${title}</div>\n              <div style=\"font-size:14px;color:#374151;line-height:1.65;font-family:${FONT};\">${body}</div>\n            </td>\n          </tr>\n        </table>\n      </td>\n    </tr>\n  </table>`;\n}\n\nsrc = src.replace(/<ol[\\s\\S]*?<\\/ol>/gi, (ol) => {\n  const items = [...ol.matchAll(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi)].map(m => m[1]);\n  if (!items.length) return ol;\n  return items.map(li => liToCard(idx++, li)).join('');\n});\n\n// 3) Assemble full email-safe HTML\nconst html = `<!DOCTYPE html>\n<html lang=\"en\"><head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width\">\n<title>Business Analysis Report</title>\n</head>\n<body style=\"margin:0;background:${C_BG};color:#2c3e50;font-family:${FONT};line-height:1.6;\">\n<!--SYNECTA-CARDS-->\n<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n  <tr>\n    <td align=\"center\" style=\"padding:24px 12px;\">\n\n      <!-- MAIN CARD -->\n      <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"max-width:600px;background:#ffffff;border-radius:18px;border:1px solid #DDE1FF;box-shadow:0 10px 40px rgba(108,99,255,0.10);\">\n\n        <!-- HEADER STRIP -->\n        <tr>\n          <td style=\"background:linear-gradient(90deg,${C_PRIMARY} 0%,${C_DARK_BLUE} 100%);border-radius:18px 18px 0 0;padding:20px 28px;\">\n            <img src=\"${LOGO_URL}\" alt=\"Logo\" height=\"36\" style=\"display:block;border:0;outline:none;text-decoration:none;\">\n          </td>\n        </tr>\n\n        <!-- BODY -->\n        <tr>\n          <td style=\"padding:28px;\">\n            <div style=\"font-size:15px;line-height:1.75;color:#374151;font-family:${FONT};\">\n              ${src}\n            </div>\n          </td>\n        </tr>\n\n        <!-- CTA BUTTON -->\n        <tr>\n          <td align=\"center\" style=\"padding:4px 28px 32px 28px;\">\n            <a href=\"${CAL_URL}\" target=\"_blank\" style=\"${CTA_INLINE}\">Book a Free Call</a>\n          </td>\n        </tr>\n\n      </table>\n\n      <!-- FOOTER -->\n      <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"max-width:600px;margin-top:16px;background:${C_DARK_BG};border-radius:16px;\">\n        <tr>\n          <td align=\"center\" style=\"padding:32px 24px;\">\n\n            <!-- Logo in footer -->\n            <img src=\"${LOGO_URL}\" alt=\"Synecta\" height=\"30\" style=\"display:block;margin:0 auto 16px auto;border:0;outline:none;text-decoration:none;\">\n\n            <!-- Social icons -->\n            <table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" style=\"margin-bottom:20px;\">\n              <tr>\n                <!-- Email -->\n                <td align=\"center\" style=\"padding:0 8px;\">\n                  <a href=\"mailto:${YOUR_EMAIL}\"\n                     style=\"display:inline-block;width:42px;height:42px;line-height:42px;text-align:center;\n                            border-radius:50%;background:rgba(108,99,255,0.15);text-decoration:none;\">\n                    <img src=\"https://img.icons8.com/fluency/48/gmail-new.png\" width=\"22\" height=\"22\" alt=\"Email\"\n                         style=\"display:inline-block;vertical-align:middle;border:0;\">\n                  </a>\n                </td>\n                <!-- Instagram -->\n                <td align=\"center\" style=\"padding:0 8px;\">\n                  <a href=\"${INSTAGRAM_URL}\" target=\"_blank\"\n                     style=\"display:inline-block;width:42px;height:42px;line-height:42px;text-align:center;\n                            border-radius:50%;background:rgba(108,99,255,0.15);text-decoration:none;\">\n                    <img src=\"https://img.icons8.com/fluency/48/instagram-new.png\" width=\"22\" height=\"22\" alt=\"Instagram\"\n                         style=\"display:inline-block;vertical-align:middle;border:0;\">\n                  </a>\n                </td>\n                <!-- LinkedIn -->\n                <td align=\"center\" style=\"padding:0 8px;\">\n                  <a href=\"${LINKEDIN_URL}\" target=\"_blank\"\n                     style=\"display:inline-block;width:42px;height:42px;line-height:42px;text-align:center;\n                            border-radius:50%;background:rgba(108,99,255,0.15);text-decoration:none;\">\n                    <img src=\"https://img.icons8.com/fluency/48/linkedin.png\" width=\"22\" height=\"22\" alt=\"LinkedIn\"\n                         style=\"display:inline-block;vertical-align:middle;border:0;\">\n                  </a>\n                </td>\n              </tr>\n            </table>\n\n            <div style=\"font-family:${FONT};font-size:13px;color:#718096;line-height:1.6;text-align:center;\">\n              This analysis was prepared specifically for your business.<br>\n              Questions? Reply directly to this email.\n            </div>\n          </td>\n        </tr>\n      </table>\n\n    </td>\n  </tr>\n</table>\n</body></html>`;\n\nreturn [{ email_html: html }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "94878d17-f8a3-4e03-8023-373ec6fb9d1b",
      "name": "Clean HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        -208,
        272
      ],
      "parameters": {
        "jsCode": "const html = $input.first().json.data || '';\nconst cleaned = html\n  .replace(/<script[\\s\\S]*?<\\/script>/gi,' ')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi,' ')\n  .replace(/<!--[\\s\\S]*?-->/g,' ')\n  .replace(/<[^>]+>/g,' ')\n  .replace(/\\s+/g,' ')\n  .trim();\n\nconst text = cleaned.slice(0, 28000); // hard limit ~6-8k tokens\nconst signals = {\n  url: $json.url || '',\n  page_title: $json.pageTitle || '',\n  has_wa: /wa\\.me|api\\.whatsapp\\.com/i.test(html),\n  has_tel: /tel:/i.test(html),\n  has_mailto: /mailto:/i.test(html),\n  has_checkout: /checkout|cart|add to cart|woocommerce/i.test(html),\n  has_booking: /calendly|book now|appointment|booking|schedule/i.test(html),\n  social: [...new Set((html.match(/instagram\\.com|linkedin\\.com|facebook\\.com|youtube\\.com/gi) || []).map(s => s.toLowerCase()))]\n};\n\nreturn [{ url: signals.url, pageTitle: signals.page_title, text, signals }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "95e76890-12ed-4d20-9b3b-a9c2f11819f3",
      "name": "Fetch Website HTML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -384,
        272
      ],
      "parameters": {
        "url": "={{ $('Form Trigger').item.json.website }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "5d21af29-a432-4a18-a09b-441e8f6772cf",
      "name": "Sticky \u2013 Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -256
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 200,
        "content": "## \ud83e\udd16 AI Business Analysis \u2013 Lead Magnet\n**What this workflow does:**\nA prospect fills in a form with their email and website URL. The workflow fetches their website, analyses it with AI, writes a personalised 10-improvement email in their language, and sends it automatically via Gmail.\n\n**Estimated run time:** ~30\u201360 seconds per lead."
      },
      "typeVersion": 1
    },
    {
      "id": "51802a2b-9bd9-4c7d-afbf-41e942d2fa61",
      "name": "Sticky \u2013 Form",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -752,
        -16
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 450,
        "content": "## \ud83d\udcdd Step 1 \u2013 Form Trigger\nA simple n8n form with two fields:\n- **Email** \u2192 where the report is sent\n- **Website URL** \u2192 the site to be analysed\n\n\ud83d\udca1 You can embed this form on your landing page or share the direct URL."
      },
      "typeVersion": 1
    },
    {
      "id": "49c426d0-0315-4e4f-a47c-62d86cf788c1",
      "name": "Sticky \u2013 Fetch & Clean",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        -16
      ],
      "parameters": {
        "color": 5,
        "width": 364,
        "height": 454,
        "content": "## \ud83c\udf10 Step 2 \u2013 Fetch & Clean Website\n**Fetch Website HTML:** Makes an HTTP GET request to the submitted URL and retrieves the raw HTML.\n\n**Clean HTML:** Strips all tags, scripts and styles, leaving only readable plain text (max 28,000 chars \u2248 7k tokens) + key signals (WhatsApp, booking links, checkout, social)."
      },
      "typeVersion": 1
    },
    {
      "id": "bc3f43f0-4633-48df-91a3-f55c95965426",
      "name": "Sticky \u2013 Analyst Agent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 508,
        "height": 644,
        "content": "## \ud83d\udd0d Step 3 \u2013 Analyst Agent\nReads the plain-text website content and returns a **structured JSON diagnostic** with:\n- Business type, offers & target audience\n- Contact channels & conversion funnels\n- 7\u201310 automatable pain points with evidence & likelihood scores\n- Copy kit: compliments, hook angles, tone, objections & improvement candidates\n\n\u2699\ufe0f Uses **gpt-4o-mini** by default. Swap for gpt-4o for higher accuracy."
      },
      "typeVersion": 1
    },
    {
      "id": "a33a6e21-c0f3-45e3-af34-1a2c86550fa1",
      "name": "Sticky \u2013 Writer Agent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        -16
      ],
      "parameters": {
        "color": 4,
        "width": 460,
        "height": 644,
        "content": "## \u270d\ufe0f Step 4 \u2013 Writer Agent\nTakes the analyst's JSON and writes a **personalised email** with:\n- A genuine opening compliment based on the site analysis\n- 10 numbered improvements in prose (benefit-focused, concise)\n- A closing CTA to book a discovery call\n\n\u26a0\ufe0f The email is automatically written in the **same language as the lead's website** (e.g. Spanish site \u2192 Spanish email)."
      },
      "typeVersion": 1
    },
    {
      "id": "4b85d9f6-10b2-4865-a3cf-155e802202b1",
      "name": "Sticky \u2013 Build HTML",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        -16
      ],
      "parameters": {
        "color": 6,
        "width": 524,
        "height": 632,
        "content": "## \ud83c\udfa8 Step 5 \u2013 Build Email HTML\nConverts the writer's plain message into a **branded HTML email** with:\n- Gradient header with your logo\n- Numbered improvement cards with brand colours\n- CTA button linking to your booking calendar\n- Dark footer with email, Instagram & LinkedIn icons\n\n\u2699\ufe0f **Configure your details at the top of this node:**\n```\nYOUR_NAME, YOUR_EMAIL, CAL_URL,\nINSTAGRAM_URL, LINKEDIN_URL, LOGO_URL\n```"
      },
      "typeVersion": 1
    },
    {
      "id": "bb607496-5c83-4a67-909a-d878c5a8222e",
      "name": "Sticky \u2013 Send Email",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        -16
      ],
      "parameters": {
        "color": 6,
        "width": 280,
        "height": 630,
        "content": "## \ud83d\udce7 Step 6 \u2013 Send Email\nSends the branded HTML report via **Gmail** to the address submitted in the form.\n\n\ud83d\udd11 **Setup required:**\n1. Connect your Gmail account under Credentials\n2. Update `senderName` to your name in the node settings\n3. The email subject is dynamically generated by the Writer Agent"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "6af6a675-fd10-4d85-a42f-319a5f0c119c",
  "connections": {
    "Clean HTML": {
      "main": [
        [
          {
            "node": "Analyst Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Trigger": {
      "main": [
        [
          {
            "node": "Fetch Website HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Writer Agent": {
      "main": [
        [
          {
            "node": "Build Email HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyst Agent": {
      "main": [
        [
          {
            "node": "Writer Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Email HTML": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Website HTML": {
      "main": [
        [
          {
            "node": "Clean HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Writer Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Writer Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Analyst Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyst Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI \u2013 Writer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Writer Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI \u2013 Analyst Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyst Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}