{
  "id": "KKe195nI9HsFACnH",
  "name": "Generate AEO strategy from brand input using AI competitor analysis",
  "tags": [],
  "nodes": [
    {
      "id": "0ed4c268-0c17-4518-ab09-9d535c90f319",
      "name": "Sticky Note - Main Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 526,
        "height": 1756,
        "content": "## \ud83c\udfaf AEO Strategy Generator with AI Competitor Analysis\n\n### What This Workflow Does\nThis workflow automatically generates a comprehensive Answer Engine Optimization (AEO) strategy by:\n1. **Collecting brand information** via a web form\n2. **Identifying top 3 competitors** using AI analysis\n3. **Scraping competitor content** to understand their positioning\n4. **Generating a custom AEO strategy** based on competitive intelligence\n5. **Delivering results via email** as a formatted report\n\n### Who It's For\n- **Digital marketers** optimizing for AI search engines (ChatGPT, Perplexity, etc.)\n- **SEO agencies** offering AEO services to clients\n- **Brand strategists** analyzing competitive positioning\n- **Content teams** creating AI-optimized content strategies\n\n### Requirements\n- **Google Gemini API key** (for competitor analysis)\n- **OpenAI API key** (for strategy generation)\n- **Firecrawl API key** (for web scraping)\n- **Gmail account** (for sending results)\n\n### Setup Instructions\n\n1. **Configure API Credentials**\n   - Add your Google Gemini API credentials\n   - Add your OpenAI API credentials  \n   - Add your Firecrawl API key in the HTTP nodes\n   - Add your Gmail credentials\n\n2. **Customize the Form**\n   - Edit the form trigger to match your branding\n   - Deploy the webhook to get your form URL\n\n3. **Test the Workflow**\n   - Submit a test form with a real brand\n   - Check email delivery\n   - Review the generated strategy\n\n### How to Customize\n\n- **Change AI Models**: Swap Google Gemini or OpenAI for other LLM providers\n- **Modify Competitor Count**: Edit the AI prompt to find more/fewer competitors\n- **Add More Data Sources**: Include social media, reviews, or G2 data\n- **Change Output Format**: Modify the email template or export to Google Docs\n- **Add Slack/Discord**: Replace Gmail with team notifications\n\n### Workflow Steps\n\n**Step 1**: User fills out form with brand details\n**Step 2**: AI agent identifies top 3 direct competitors\n**Step 3**: Firecrawl scrapes target brand website\n**Step 4**: Firecrawl scrapes competitor websites in parallel  \n**Step 5**: AI generates comprehensive AEO strategy\n**Step 6**: Results sent via email\n\n---\n\n\ud83d\udca1 **Pro Tip**: For best results, ensure the brand website has clear product/service information for the AI to analyze."
      },
      "typeVersion": 1
    },
    {
      "id": "279c4e93-95e1-4428-aedd-750b68927399",
      "name": "Sticky Note - Step 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 325,
        "height": 237,
        "content": "## \ud83d\udccb Step 1: Collect Brand Information\n\nUsers submit a form with:\n- Brand Name\n- Website URL\n- Niche (B2B/D2C/B2C)\n- Product Type\n- Email for delivery\n\nThe form trigger creates a webhook that captures these inputs for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "4de0225e-771b-4f35-a17b-fb5bfa3b7a22",
      "name": "Sticky Note - Step 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 342,
        "height": 283,
        "content": "## \ud83d\udd0d Step 2: AI Competitor Analysis\n\nGoogle Gemini AI analyzes the brand and identifies the top 3 direct competitors based on:\n- Product/service overlap (40%)\n- Market position (30%)\n- Digital presence (20%)\n- Geographic overlap (10%)\n\nOutputs competitor names and URLs in structured JSON format."
      },
      "typeVersion": 1
    },
    {
      "id": "f8367873-eff8-495f-892d-f4aaa16bb682",
      "name": "Sticky Note - Step 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -32
      ],
      "parameters": {
        "color": 7,
        "width": 324,
        "height": 298,
        "content": "## \ud83c\udf10 Step 3: Web Scraping\n\nFirecrawl API scrapes:\n- **Target brand website** (main URL)\n- **All 3 competitor websites** (in parallel)\n\nExtracts:\n- Product descriptions\n- Value propositions  \n- Target audience info\n- Key messaging\n- Content themes"
      },
      "typeVersion": 1
    },
    {
      "id": "5a353a4a-0cfd-4ec7-b668-9fe0ec95271b",
      "name": "Sticky Note - Step 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2528,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 359,
        "height": 319,
        "content": "## \ud83e\udd16 Step 4: AEO Strategy Generation\n\nOpenAI GPT-4 analyzes:\n- Brand positioning vs competitors\n- Content gaps and opportunities\n- Answer Engine optimization tactics\n\nGenerates:\n- 15+ specific AEO recommendations\n- Content topics to create\n- Optimization priorities\n- Competitive advantages to emphasize"
      },
      "typeVersion": 1
    },
    {
      "id": "58c0c777-dde6-41c4-bde8-55450b0e5705",
      "name": "Sticky Note - Step 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2976,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 329,
        "height": 283,
        "content": "## \ud83d\udce7 Step 5: Deliver Results\n\nFormatted HTML email sent to the provided address containing:\n- Executive summary\n- Competitor analysis\n- Detailed AEO strategy\n- Action items\n- Next steps\n\nCustomize the email template in the \"Format Email Content\" node."
      },
      "typeVersion": 1
    },
    {
      "id": "a8a45e17-5938-4167-9e84-b070649059b0",
      "name": "Form Trigger - Brand Input",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        528,
        400
      ],
      "parameters": {
        "options": {},
        "formTitle": "AEO Strategy Generator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Brand Name",
              "requiredField": true
            },
            {
              "fieldLabel": "Website Link",
              "requiredField": true
            },
            {
              "fieldLabel": "Niche (D2C or B2C)",
              "requiredField": true
            },
            {
              "fieldLabel": "Product Type",
              "requiredField": true
            },
            {
              "fieldType": "email",
              "fieldLabel": "Email",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Get a custom Answer Engine Optimization strategy for your brand"
      },
      "typeVersion": 2.3
    },
    {
      "id": "191a4c85-8ce1-467a-9f92-f86f2d39a711",
      "name": "Set - Brand Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        736,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "80848d3f-22bc-4c16-9309-3165054f66dd",
              "name": "brand_name",
              "type": "string",
              "value": "={{ $json[\"Brand Name\"] }}"
            },
            {
              "id": "d2c3fef9-7935-479b-8b7c-cdb188616fca",
              "name": "website_url",
              "type": "string",
              "value": "={{ $json[\"Website Link\"] }}"
            },
            {
              "id": "eac20759-a54c-4f9f-9812-9a8188f3a6e4",
              "name": "niche",
              "type": "string",
              "value": "={{ $json[\"Niche (D2C or B2C)\"] }}"
            },
            {
              "id": "8bc6c9de-ec31-476c-9480-0dada0b85933",
              "name": "product_type",
              "type": "string",
              "value": "={{ $json[\"Product Type\"] }}"
            },
            {
              "id": "ea2ce803-7470-4f46-924b-f44bd493e513",
              "name": "user_email",
              "type": "string",
              "value": "={{ $json.Email }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0e752e80-d0e4-409c-935c-1c60c3c35ba8",
      "name": "AI Agent - Identify Competitors",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        896,
        400
      ],
      "parameters": {
        "text": "=# AI Agent Prompt: Competitor Identification\n\n## SYSTEM PROMPT (Role Definition)\n\nYou are a competitive intelligence analyst with expertise in market research and brand positioning. Your specialty is identifying direct and indirect competitors across various industries, with a focus on digital presence and market overlap.\n\nYou have deep knowledge of:\n- Market segmentation and positioning\n- Business model analysis\n- Product/service categorization\n- Competitive landscape mapping\n- Digital marketing and AEO strategies\n\n## USER PROMPT (Task Instructions)\n\n### INPUT DATA:\n- **Brand Name**: {{ $json.brand_name }}\n- **Website URL**: {{ $json.website_url }}\n- **Niche**: {{ $json.niche }}\n- **Product Type**: {{ $json.product_type }}\n\n### YOUR TASK:\nIdentify the **top 3 direct competitors** for this brand based on the following criteria:\n\n#### ANALYSIS CRITERIA:\n1. **Product/Service Overlap** (40% weight)\n   - Similar offerings or solutions\n   - Comparable target audience\n   - Overlapping use cases\n\n2. **Market Position** (30% weight)\n   - Similar market segment (enterprise, mid-market, SMB, consumer)\n   - Comparable pricing tier\n   - Similar brand maturity\n\n3. **Digital Presence** (20% weight)\n   - Active in the same channels\n   - Competing for similar search terms\n   - Similar content strategy\n\n4. **Geographic Overlap** (10% weight)\n   - Operating in same regions\n   - Same language markets\n\n#### COMPETITOR SELECTION RULES:\n\u2705 **DO select competitors that:**\n- Offer substantially similar products/services\n- Target the same customer segment\n- Would appear in comparison searches\n- Customers would realistically choose between\n\n\u274c **DO NOT select:**\n- Companies in completely different industries\n- Vastly different price points (budget vs. luxury)\n- Different business models (B2B vs. B2C)\n- Generic technology providers (unless that's what the brand is)\n\n### RESEARCH PROCESS:\n1. Analyze the brand's core offering and positioning\n2. Consider their target market and customer profile\n3. Identify companies solving similar problems\n4. Prioritize by relevance and market overlap\n5. Verify each competitor has an active digital presence\n\n### OUTPUT FORMAT (JSON):\n\nReturn your response in this exact JSON structure:\n\n```json\n{\n  \"brand_analyzed\": \"Brand Name\",\n  \"industry_category\": \"Brief industry classification\",\n  \"competitors\": [\n    {\n      \"rank\": 1,\n      \"company_name\": \"Competitor Name\",\n      \"website_url\": \"https://www.competitor.com\",\n      \"reasoning\": \"2-3 sentence explanation\",\n      \"overlap_percentage\": 85,\n      \"key_similarities\": [\n        \"Similarity 1\",\n        \"Similarity 2\",\n        \"Similarity 3\"\n      ],\n      \"differentiators\": [\n        \"Differentiator 1\",\n        \"Differentiator 2\"\n      ]\n    },\n    {\n      \"rank\": 2,\n      \"company_name\": \"Competitor Name 2\",\n      \"website_url\": \"https://www.competitor2.com\",\n      \"reasoning\": \"Explanation for #2 ranking\",\n      \"overlap_percentage\": 75,\n      \"key_similarities\": [\n        \"Similarity 1\",\n        \"Similarity 2\",\n        \"Similarity 3\"\n      ],\n      \"differentiators\": [\n        \"Differentiator 1\",\n        \"Differentiator 2\"\n      ]\n    },\n    {\n      \"rank\": 3,\n      \"company_name\": \"Competitor Name 3\",\n      \"website_url\": \"https://www.competitor3.com\",\n      \"reasoning\": \"Explanation for #3 ranking\",\n      \"overlap_percentage\": 70,\n      \"key_similarities\": [\n        \"Similarity 1\",\n        \"Similarity 2\",\n        \"Similarity 3\"\n      ],\n      \"differentiators\": [\n        \"Differentiator 1\",\n        \"Differentiator 2\"\n      ]\n    }\n  ],\n  \"analysis_notes\": \"Brief note about the competitive landscape\",\n  \"alternative_competitors\": [\n    \"Company Name 4\",\n    \"Company Name 5\"\n  ]\n}\n```\n\n### IMPORTANT REQUIREMENTS:\n\n1. **URL Accuracy**: All competitor URLs must be valid and active\n2. **Relevance**: Only include true competitors, not loosely related companies\n3. **Recency**: Prioritize currently active competitors (not defunct companies)\n4. **Verification**: Ensure each company actually competes in the same space\n5. **Objectivity**: Base rankings on factual overlap, not brand size alone\n\n### QUALITY CHECKLIST:\n\nBefore submitting, verify:\n- \u2705 All 3 competitors are truly comparable\n- \u2705 Website URLs are complete and valid (include https://)\n- \u2705 Overlap percentages are realistic and justified\n- \u2705 Reasoning is specific, not generic\n- \u2705 JSON is properly formatted\n- \u2705 No placeholder text\n\nProvide the top 3 competitors in the exact JSON format specified above.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "f81b4735-21b0-4a80-8f73-38f4557a3c86",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        896,
        576
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "cf7e1394-a9cd-4a8d-bd74-09d9548a40f6",
      "name": "Parse Competitor Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1200,
        400
      ],
      "parameters": {
        "jsCode": "// Parse the AI response to extract competitor data\nconst response = $input.first().json.output;\n\n// Try to extract JSON from the response\nlet competitors;\ntry {\n  // Try to parse directly\n  competitors = JSON.parse(response);\n} catch (e) {\n  // Try to extract JSON from markdown code blocks\n  const jsonMatch = response.match(/```json\\n([\\s\\S]*?)\\n```/);\n  if (jsonMatch) {\n    competitors = JSON.parse(jsonMatch[1]);\n  } else {\n    // Try to find JSON object in the text\n    const objMatch = response.match(/\\{[\\s\\S]*\\}/);\n    if (objMatch) {\n      competitors = JSON.parse(objMatch[0]);\n    } else {\n      throw new Error('Could not extract JSON from response');\n    }\n  }\n}\n\n// Extract competitor URLs and names\nconst competitorData = competitors.competitors.map(comp => ({\n  competitor_name: comp.company_name,\n  competitor_url: comp.website_url,\n  overlap_percentage: comp.overlap_percentage,\n  reasoning: comp.reasoning\n}));\n\n// Return structured data\nreturn [\n  {\n    json: {\n      brand_name: $input.first().json.brand_name,\n      website_url: $input.first().json.website_url,\n      niche: $input.first().json.niche,\n      product_type: $input.first().json.product_type,\n      user_email: $input.first().json.user_email,\n      competitor_urls: competitorData.map(c => c.competitor_url),\n      competitors: competitorData\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "0140d35c-e081-430c-aed3-4815e3a52237",
      "name": "Split Out - Individual Competitors",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1408,
        400
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "=competitors"
      },
      "typeVersion": 1
    },
    {
      "id": "b3db184b-1c3e-4703-8379-d17254c2366d",
      "name": "Scrape Target Brand Website",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1600,
        512
      ],
      "parameters": {
        "url": "https://api.firecrawl.dev/v2/extract",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.website_url }}"
            },
            {
              "name": "schema",
              "value": "={\"type\": \"object\", \"properties\": {\"company_name\": {\"type\": \"string\"}, \"products_services\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}, \"value_proposition\": {\"type\": \"string\"}, \"target_audience\": {\"type\": \"string\"}, \"key_features\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}, \"pricing_info\": {\"type\": \"string\"}, \"content_themes\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "385a6108-353f-44a9-9a8f-a6f55daf569d",
      "name": "Scrape Competitor Websites",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1600,
        272
      ],
      "parameters": {
        "url": "https://api.firecrawl.dev/v2/extract",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "url",
              "value": "={{ $json.competitor_url }}"
            },
            {
              "name": "schema",
              "value": "={\"type\": \"object\", \"properties\": {\"company_name\": {\"type\": \"string\"}, \"products_services\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}, \"value_proposition\": {\"type\": \"string\"}, \"target_audience\": {\"type\": \"string\"}, \"key_features\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}, \"pricing_info\": {\"type\": \"string\"}, \"content_themes\": {\"type\": \"array\", \"items\": {\"type\": \"string\"}}}}"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bed46dcf-aee6-4879-b068-b8b100160ce3",
      "name": "Wait - Brand Scraping",
      "type": "n8n-nodes-base.wait",
      "position": [
        1808,
        512
      ],
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "c23479c5-e0f2-4feb-8b12-8b79ff85dd9a",
      "name": "Wait - Competitor Scraping",
      "type": "n8n-nodes-base.wait",
      "position": [
        1808,
        272
      ],
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "08b3d94d-09ed-4d86-a356-60456c919f80",
      "name": "Extract Brand Job ID",
      "type": "n8n-nodes-base.code",
      "position": [
        2032,
        512
      ],
      "parameters": {
        "jsCode": "// Get the Firecrawl job ID from the response\nconst jobId = $input.first().json.id;\n\nreturn [{\n  json: {\n    job_id: jobId,\n    url: $input.first().json.url\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7270bad6-0347-4561-86dc-c0dab6cfaa26",
      "name": "Extract Competitor Job IDs",
      "type": "n8n-nodes-base.code",
      "position": [
        2032,
        272
      ],
      "parameters": {
        "jsCode": "// Get the Firecrawl job ID from the response\nconst jobId = $input.first().json.id;\n\nreturn [{\n  json: {\n    job_id: jobId,\n    competitor_url: $input.first().json.url\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "d384d46d-070e-4050-b4ec-8e030977b869",
      "name": "Get Brand Scrape Results",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2256,
        512
      ],
      "parameters": {
        "url": "=https://api.firecrawl.dev/v2/extract/{{ $json.job_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "76447198-f178-4626-a09f-a2470cf49fe7",
      "name": "Get Competitor Scrape Results",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2256,
        272
      ],
      "parameters": {
        "url": "=https://api.firecrawl.dev/v2/extract/{{ $json.job_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "9b15dc04-383b-453a-b39a-a19800199793",
      "name": "Merge Brand & Competitor Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2496,
        400
      ],
      "parameters": {
        "mode": "combine",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "b8077839-85da-444a-ac4a-193524034086",
      "name": "AI Agent - Generate AEO Strategy",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2672,
        400
      ],
      "parameters": {
        "text": "=# AEO Strategy Generation Prompt\n\n## Context\nYou are an Answer Engine Optimization (AEO) specialist helping brands optimize their content for AI-powered search engines like ChatGPT, Perplexity, Google SGE, and Bing Chat.\n\n## Input Data\n\n### Target Brand:\n{{ $json.brand_data }}\n\n### Competitor Analysis:\n{{ $json.competitor_data }}\n\n## Your Task\n\nGenerate a comprehensive AEO strategy report that includes:\n\n### 1. Executive Summary\n- Brief overview of the brand's current positioning\n- Key competitive advantages\n- Top 3 AEO opportunities\n\n### 2. Competitive Analysis\n- How competitors are positioning themselves\n- Content gaps we can exploit\n- Unique angles the brand can take\n\n### 3. AEO Strategy Recommendations (15+ specific tactics)\n\nProvide actionable recommendations in these categories:\n\n**Content Optimization:**\n- Specific topics to create content around\n- Question-answer formats to implement\n- Long-tail keywords and phrases\n\n**Structural Improvements:**\n- Schema markup suggestions\n- FAQ sections to add\n- How-to content opportunities\n\n**Authority Building:**\n- Expert quotes and citations to include\n- Statistics and data points to reference\n- Case studies or examples to showcase\n\n**Answer Engine Targeting:**\n- Specific queries the brand should optimize for\n- Natural language patterns to incorporate\n- Featured snippet opportunities\n\n### 4. Content Priority Matrix\nList 10 content pieces to create, ranked by:\n- Search volume potential\n- Competitive advantage\n- Implementation ease\n\n### 5. Next Steps\n- Immediate actions (Week 1)\n- Short-term goals (Month 1)\n- Long-term strategy (Quarter 1)\n\n## Output Format\n\nProvide a well-structured, detailed report in HTML format with:\n- Clear headings and subheadings\n- Bullet points for easy scanning\n- Specific, actionable recommendations\n- No generic advice\n\nMake it professional, comprehensive, and immediately actionable.",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "32df1cb1-1242-4ba5-be35-7a33560e7623",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2688,
        544
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "796cd127-53c0-4d44-a4c6-47cfa1f54583",
      "name": "Format Email Content",
      "type": "n8n-nodes-base.code",
      "position": [
        2976,
        400
      ],
      "parameters": {
        "jsCode": "// Format the AEO strategy as HTML email\nconst strategy = $input.first().json.output;\nconst brandName = $input.first().json.brand_name || 'Your Brand';\nconst userEmail = $input.first().json.user_email;\n\nconst htmlEmail = `\n<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 800px; margin: 0 auto; padding: 20px; }\n    h1 { color: #2c3e50; border-bottom: 3px solid #3498db; padding-bottom: 10px; }\n    h2 { color: #34495e; margin-top: 30px; }\n    h3 { color: #7f8c8d; }\n    ul { padding-left: 20px; }\n    li { margin-bottom: 8px; }\n    .highlight { background-color: #f1c40f; padding: 2px 6px; border-radius: 3px; }\n    .section { background-color: #ecf0f1; padding: 15px; border-radius: 5px; margin: 20px 0; }\n    .footer { margin-top: 40px; padding-top: 20px; border-top: 1px solid #bdc3c7; font-size: 0.9em; color: #7f8c8d; }\n  </style>\n</head>\n<body>\n  <h1>\ud83c\udfaf AEO Strategy Report for ${brandName}</h1>\n  \n  <div class=\"section\">\n    <p><strong>Generated:</strong> ${new Date().toLocaleDateString()}</p>\n    <p>This report contains a comprehensive Answer Engine Optimization (AEO) strategy based on competitive analysis and AI-powered insights.</p>\n  </div>\n  \n  ${strategy}\n  \n  <div class=\"footer\">\n    <p>This report was generated automatically by the AEO Optimization Workflow.</p>\n    <p>For questions or support, contact your workflow administrator.</p>\n  </div>\n</body>\n</html>\n`;\n\nreturn [{\n  json: {\n    to: userEmail,\n    subject: `AEO Strategy Report: ${brandName}`,\n    html: htmlEmail,\n    brand_name: brandName\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "cf8cd495-37a7-4b93-b18c-bbf6b62d1622",
      "name": "Send Email via Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3152,
        400
      ],
      "parameters": {
        "sendTo": "={{ $json.to }}",
        "message": "={{ $json.html }}",
        "options": {},
        "subject": "={{ $json.subject }}"
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "53263ef0-fd57-450d-bcbe-f262c65de866",
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Generate AEO Strategy",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Brand Job ID": {
      "main": [
        [
          {
            "node": "Get Brand Scrape Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email Content": {
      "main": [
        [
          {
            "node": "Send Email via Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Competitor Data": {
      "main": [
        [
          {
            "node": "Split Out - Individual Competitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set - Brand Variables": {
      "main": [
        [
          {
            "node": "AI Agent - Identify Competitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - Brand Scraping": {
      "main": [
        [
          {
            "node": "Extract Brand Job ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Brand Scrape Results": {
      "main": [
        [
          {
            "node": "Merge Brand & Competitor Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent - Identify Competitors",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Competitor Job IDs": {
      "main": [
        [
          {
            "node": "Get Competitor Scrape Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Form Trigger - Brand Input": {
      "main": [
        [
          {
            "node": "Set - Brand Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Competitor Websites": {
      "main": [
        [
          {
            "node": "Wait - Competitor Scraping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait - Competitor Scraping": {
      "main": [
        [
          {
            "node": "Extract Competitor Job IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Target Brand Website": {
      "main": [
        [
          {
            "node": "Wait - Brand Scraping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Competitor Scrape Results": {
      "main": [
        [
          {
            "node": "Merge Brand & Competitor Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge Brand & Competitor Data": {
      "main": [
        [
          {
            "node": "AI Agent - Generate AEO Strategy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Identify Competitors": {
      "main": [
        [
          {
            "node": "Parse Competitor Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent - Generate AEO Strategy": {
      "main": [
        [
          {
            "node": "Format Email Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out - Individual Competitors": {
      "main": [
        [
          {
            "node": "Scrape Target Brand Website",
            "type": "main",
            "index": 0
          },
          {
            "node": "Scrape Competitor Websites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}