{
  "id": "sZ4mUSIRda2i40ue",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Competitor Intelligence Briefing: Daily Monitoring with OpenAI and Gmail",
  "tags": [
    {
      "id": "PJHmDVSIwAcSkpjQ",
      "name": "AI",
      "createdAt": "2026-04-07T08:58:19.581Z",
      "updatedAt": "2026-04-07T08:58:19.581Z"
    },
    {
      "id": "SzTdBpsW5xAM158h",
      "name": "Marketing",
      "createdAt": "2026-04-07T08:58:19.644Z",
      "updatedAt": "2026-04-07T08:58:19.644Z"
    },
    {
      "id": "hFw2FRH6cpExzN0f",
      "name": "OpenAI",
      "createdAt": "2026-04-07T08:58:19.665Z",
      "updatedAt": "2026-04-07T08:58:19.665Z"
    },
    {
      "id": "nVqSqPZdrsVxy6rM",
      "name": "Competitive Intelligence",
      "createdAt": "2026-04-07T08:58:19.559Z",
      "updatedAt": "2026-04-07T08:58:19.559Z"
    },
    {
      "id": "wluCw4wLLORaZtzq",
      "name": "Daily Briefing",
      "createdAt": "2026-04-07T08:58:19.622Z",
      "updatedAt": "2026-04-07T08:58:19.622Z"
    }
  ],
  "nodes": [
    {
      "id": "a49040e9-cf7e-4a6f-8268-bd821345361d",
      "name": "Daily 8AM Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1424,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "02210b2e-bc4d-43ef-8f08-76fac45f4323",
      "name": "Configure Competitors and Settings",
      "type": "n8n-nodes-base.code",
      "position": [
        1664,
        0
      ],
      "parameters": {
        "jsCode": "/* ==================================================\n   \ufe0f  CONFIGURE THIS NODE \u2014 All your settings here\n   ================================================== */\n\n// 1. Who receives the daily briefing?\nconst REPORT_EMAIL = 'user@example.com';\n\n// 2. Your company name (used in AI prompts)\nconst YOUR_COMPANY = 'Acme Corp';\n\n// 3. Your market/product category (for relevant insights)\nconst YOUR_FOCUS = 'B2B SaaS project management tools';\n\n// 4. Add your competitors below.\n//    url:       the page to visit (homepage or pricing page works best)\n//    watch_for: tells the AI which signals matter for each competitor\nconst COMPETITORS = [\n  {\n    name: 'Competitor Alpha',\n    url: 'https://www.competitor-alpha.com',\n    watch_for: 'pricing tiers, new feature announcements, customer testimonials, messaging changes'\n  },\n  {\n    name: 'Competitor Beta',\n    url: 'https://www.competitor-beta.com',\n    watch_for: 'integrations, enterprise moves, product roadmap hints, partnerships'\n  },\n  {\n    name: 'Competitor Gamma',\n    url: 'https://www.competitor-gamma.com',\n    watch_for: 'go-to-market strategy, pricing model, positioning, new use cases'\n  }\n];\n\n/* ===================================\n   DO NOT EDIT BELOW THIS LINE\n   =================================== */\n\nconst today = new Date().toISOString().split('T')[0];\n\nreturn COMPETITORS.map(c => ({\n  json: {\n    competitor_name: c.name,\n    competitor_url: c.url,\n    watch_for: c.watch_for,\n    report_email: REPORT_EMAIL,\n    your_company: YOUR_COMPANY,\n    your_focus: YOUR_FOCUS,\n    run_date: today\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "53a7fd51-f7d0-43fe-b24a-156201b521ec",
      "name": "Fetch Competitor Page",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1888,
        0
      ],
      "parameters": {
        "url": "={{ $json.competitor_url }}",
        "options": {
          "timeout": 20000,
          "redirect": {
            "redirect": {
              "maxRedirects": 5
            }
          },
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.2,
      "continueOnFail": true
    },
    {
      "id": "85a8da5a-e050-488b-9922-a51805577e54",
      "name": "Extract Text and Build AI Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        2112,
        0
      ],
      "parameters": {
        "jsCode": "// Clean raw HTML and build the per-competitor OpenAI request\nconst htmlData = $input.item.json;\nconst cfg = $('Configure Competitors and Settings').item.json;\n\nlet rawHtml = '';\nif (typeof htmlData === 'string') {\n  rawHtml = htmlData;\n} else if (htmlData && typeof htmlData.data === 'string') {\n  rawHtml = htmlData.data;\n} else {\n  rawHtml = JSON.stringify(htmlData);\n}\n\n// Strip scripts, styles, nav, SVGs and all remaining HTML tags\nconst pageText = rawHtml\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, '')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, '')\n  .replace(/<svg[\\s\\S]*?<\\/svg>/gi, '')\n  .replace(/<nav[\\s\\S]*?<\\/nav>/gi, '')\n  .replace(/<footer[\\s\\S]*?<\\/footer>/gi, '')\n  .replace(/<head[\\s\\S]*?<\\/head>/gi, '')\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/&amp;/g, '&')\n  .replace(/&lt;/g, '<')\n  .replace(/&gt;/g, '>')\n  .replace(/&nbsp;/g, ' ')\n  .replace(/&#[0-9]+;/g, ' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .slice(0, 4500);\n\nconst systemMsg = 'You are a senior competitive intelligence analyst working for ' + cfg.your_company + ', competing in the ' + cfg.your_focus + ' market. Extract concise, actionable intelligence from competitor website content. Be specific. Skip filler.';\n\nconst userMsg = 'Analyze this content from ' + cfg.competitor_name + ' website (' + cfg.competitor_url + ').\\n\\nWatch specifically for: ' + cfg.watch_for + '\\n\\n--- SCRAPED CONTENT ---\\n' + (pageText || 'ERROR: Page could not be loaded.') + '\\n--- END ---\\n\\nRespond with EXACTLY this structure (no extra text):\\n\\nCOMPETITOR: ' + cfg.competitor_name + '\\n\\nKEY SIGNALS (max 4 bullet points):\\n- [signal]\\n- [signal]\\n\\nTHREAT LEVEL: [High / Medium / Low]\\nReason: [one sentence]\\n\\nRECOMMENDED ACTION for ' + cfg.your_company + ': [1-2 sentences]\\n\\nIf the content is an error page, CAPTCHA wall, or too thin to analyze, state that clearly.';\n\nconst openaiBody = {\n  model: 'gpt-4o-mini',\n  max_tokens: 500,\n  temperature: 0.3,\n  messages: [\n    { role: 'system', content: systemMsg },\n    { role: 'user', content: userMsg }\n  ]\n};\n\nreturn [{\n  json: {\n    competitor_name: cfg.competitor_name,\n    competitor_url: cfg.competitor_url,\n    watch_for: cfg.watch_for,\n    report_email: cfg.report_email,\n    your_company: cfg.your_company,\n    your_focus: cfg.your_focus,\n    run_date: cfg.run_date,\n    openai_body: JSON.stringify(openaiBody)\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "4a3497e1-cbfd-451b-a0f8-fcb2ca200ca9",
      "name": "AI Analyze Competitor",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2320,
        0
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "options": {
          "timeout": 45000
        },
        "jsonBody": "={{ $json.openai_body }}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "24a049b2-0809-4482-9cdc-43e44c508959",
      "name": "Parse AI Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2544,
        0
      ],
      "parameters": {
        "jsCode": "// Extract the AI analysis text and carry forward all metadata\nconst res = $input.item.json;\nconst ctx = $('Extract Text and Build AI Prompt').item.json;\n\nconst analysis = res.choices?.[0]?.message?.content\n  || '**Analysis unavailable** \u2014 check your OpenAI credential or the target URL.';\n\nreturn [{\n  json: {\n    competitor_name: ctx.competitor_name,\n    competitor_url: ctx.competitor_url,\n    analysis: analysis,\n    report_email: ctx.report_email,\n    your_company: ctx.your_company,\n    your_focus: ctx.your_focus,\n    run_date: ctx.run_date\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "cd2d24f5-9c19-418e-bd8a-e0fe60c49237",
      "name": "Aggregate and Build Briefing Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        2768,
        0
      ],
      "parameters": {
        "jsCode": "// Aggregate all per-competitor analyses and build the final briefing request\nconst all = $input.all();\n\nif (!all || all.length === 0) {\n  throw new Error('No competitor analyses received -- check the upstream nodes.');\n}\n\nconst first = all[0].json;\nconst today = first.run_date || new Date().toISOString().split('T')[0];\n\n// Build individual competitor sections for the final prompt\nconst analysisBlocks = all.map(function(item) {\n  return '=== ' + item.json.competitor_name + ' (' + item.json.competitor_url + ') ===\\n' + item.json.analysis + '\\n';\n}).join('\\n');\n\nconst systemMsg = 'You are the VP of Competitive Intelligence at ' + first.your_company + ', operating in the ' + first.your_focus + ' market. You write sharp, executive-ready intelligence briefings in HTML for email. Every word earns its place. Leadership reads this before their 9AM standup.';\n\nconst userMsg = 'Today is ' + today + '. Our automated monitoring has analyzed ' + all.length + ' competitor(s).\\n\\nIndividual competitor reports:\\n\\n' + analysisBlocks + '\\n---\\nWrite a Daily Competitor Intelligence Briefing in clean HTML (email-safe). Use this exact structure:\\n\\n<h2>Executive summary</h2>\\n2-3 sentences covering the single most important competitive development and overall landscape.\\n\\n<h2>Competitor snapshots</h2>\\nFor each competitor: their name as a subheading, and 2-3 key insight bullets.\\n\\n<h2>Priority actions for ' + first.your_company + '</h2>\\nTop 3 actions, ranked by urgency. Bold action name, one-sentence rationale each.\\n\\n<h2>Watch list</h2>\\n2 things to monitor this week based on today signals.\\n\\nRules: Clean HTML only. Use strong, ul, li, p, h2, h3 tags. No inline CSS. No markdown. Scannable. No fluff.';\n\nconst openaiBody = {\n  model: 'gpt-4o',\n  max_tokens: 1800,\n  temperature: 0.4,\n  messages: [\n    { role: 'system', content: systemMsg },\n    { role: 'user', content: userMsg }\n  ]\n};\n\nreturn [{\n  json: {\n    report_email: first.report_email,\n    your_company: first.your_company,\n    your_focus: first.your_focus,\n    run_date: today,\n    competitor_count: all.length,\n    openai_body: JSON.stringify(openaiBody)\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "c3333ac2-8f69-403c-804e-317dc844a155",
      "name": "AI Generate Final Briefing",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2992,
        0
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "jsonBody": "={{ $json.openai_body }}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi"
      },
      "typeVersion": 4.2
    },
    {
      "id": "2a35d57b-5111-4370-8fc6-19c97c3d6efd",
      "name": "Format HTML Email",
      "type": "n8n-nodes-base.code",
      "position": [
        3200,
        0
      ],
      "parameters": {
        "jsCode": "// Wrap the AI-generated HTML in a styled email template\nconst res = $input.item.json;\nconst meta = $('Aggregate and Build Briefing Prompt').item.json;\n\nconst bodyHtml = res.choices && res.choices[0] && res.choices[0].message && res.choices[0].message.content\n  ? res.choices[0].message.content\n  : '<p><strong>Error:</strong> Briefing generation failed. Check your OpenAI credentials.</p>';\n\nconst emailHtml = [\n  '<!DOCTYPE html><html lang=\"en\"><head>',\n  '<meta charset=\"UTF-8\">',\n  '<meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">',\n  '<title>Competitor Intelligence Briefing</title>',\n  '<style>',\n  '*{box-sizing:border-box;margin:0;padding:0}',\n  'body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Arial,sans-serif;background:#f8fafc;color:#1e293b}',\n  '.wrapper{max-width:680px;margin:0 auto;background:#fff;border-radius:8px;overflow:hidden}',\n  '.header{background:#1e293b;color:#fff;padding:28px 32px}',\n  '.header h1{font-size:20px;font-weight:700;margin-bottom:4px}',\n  '.header p{font-size:13px;color:#94a3b8}',\n  '.body{padding:28px 32px}',\n  'h2{font-size:17px;font-weight:600;color:#1e293b;margin:24px 0 10px;padding-bottom:8px;border-bottom:1px solid #e2e8f0}',\n  'h2:first-child{margin-top:0}',\n  'h3{font-size:15px;font-weight:600;color:#334155;margin:16px 0 8px}',\n  'p{font-size:14px;line-height:1.65;color:#475569;margin-bottom:10px}',\n  'ul{padding-left:20px;margin-bottom:12px}',\n  'li{font-size:14px;color:#475569;line-height:1.65;margin-bottom:5px}',\n  'strong{color:#1e293b}',\n  '.footer{background:#f8fafc;border-top:1px solid #e2e8f0;padding:14px 32px;font-size:11px;color:#94a3b8;text-align:center}',\n  '</style></head><body>',\n  '<div class=\"wrapper\">',\n  '<div class=\"header\">',\n  '<h1>Competitor Intelligence Briefing</h1>',\n  '<p>' + meta.your_company + ' &nbsp;&middot;&nbsp; ' + meta.run_date + ' &nbsp;&middot;&nbsp; ' + meta.competitor_count + ' competitor(s) monitored</p>',\n  '</div>',\n  '<div class=\"body\">' + bodyHtml + '</div>',\n  '<div class=\"footer\">Auto-generated by n8n AI Competitor Intelligence Workflow</div>',\n  '</div></body></html>'\n].join('');\n\nconst plainText = bodyHtml.replace(/<[^>]+>/g, ' ').replace(/\\s+/g, ' ').trim();\n\nreturn [{\n  json: {\n    email_html: emailHtml,\n    email_plain: plainText,\n    report_email: meta.report_email,\n    your_company: meta.your_company,\n    run_date: meta.run_date,\n    competitor_count: meta.competitor_count\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "42d55918-3ca8-4a54-953a-9fc43cbd2a4d",
      "name": "Send Email Briefing",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3424,
        -128
      ],
      "parameters": {
        "sendTo": "={{ $json.report_email }}",
        "message": "={{ $json.email_html }}",
        "options": {},
        "subject": "={{ 'Competitor Briefing - ' + $json.run_date + ' (' + $json.competitor_count + ' competitors)' }}"
      },
      "typeVersion": 2.1
    },
    {
      "id": "9ee87063-688f-438f-b7a4-05c77f977e2b",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3424,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.run_date }}",
            "Company": "={{ $json.your_company }}",
            "Briefing Summary": "={{ $json.email_plain }}",
            "Competitors Analyzed": "={{ $json.competitor_count }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Intelligence Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "PASTE_YOUR_GOOGLE_SHEET_ID_HERE"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "11940151-282d-4363-b02c-01ec5cf9fcd4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        -496
      ],
      "parameters": {
        "color": 0,
        "width": 460,
        "height": 1116,
        "content": "## AI Competitor Intelligence Briefing using OpenAI and Gmail\n\nKnow what your competitors are doing every morning before your first meeting. This workflow visits each competitor website daily, uses AI to analyse it for strategic signals, and emails your team a consolidated executive briefing automatically.\n\n### How it works\n\n1. A schedule trigger fires every morning at 8AM.\n2. The Configure node loops through each competitor URL you have added.\n3. Each competitor page is fetched and stripped down to clean readable text.\n4. OpenAI GPT-4o-mini reads the content and extracts key signals, threat level, and recommended actions.\n5. All individual analyses are aggregated and sent to GPT-4o to write a consolidated executive briefing.\n6. The briefing is formatted as a clean HTML email and sent to your team via Gmail.\n7. Every run is logged to Google Sheets with the date, competitors analysed, and a summary.\n\n### Setup steps\n\n- [ ] **Competitors** -- Open the Configure Competitors and Settings node. Replace the placeholder URLs with your real competitor URLs and update the watch_for fields to describe what matters for each one.\n- [ ] **Your details** -- In the same node, set YOUR_COMPANY to your company name and YOUR_FOCUS to your market category.\n- [ ] **OpenAI** -- Add your OpenAI API key as a credential named OpenAI account. Get your key at platform.openai.com.\n- [ ] **Gmail** -- Connect your Gmail account in the Send Email Briefing node. Update the REPORT_EMAIL value in the Configure node to your team email address.\n- [ ] **Google Sheets** -- Create a sheet with columns: Date, Company, Competitors Analyzed, Briefing Summary. Open the Log to Google Sheets node, connect your Google account, and replace YOUR_GOOGLE_SHEET_ID with your actual sheet ID from the URL.\n- [ ] Activate the workflow. It will run automatically every morning at 8AM.\n\n### Customization\n\nChange the trigger time in Daily 8AM Trigger to any hour that suits your team. Add more competitors in the Configure node -- the workflow handles any number. Swap GPT-4o-mini for GPT-4o in the AI Analyze Competitor node for deeper per-competitor analysis at higher cost."
      },
      "typeVersion": 1
    },
    {
      "id": "4d333e41-6ddf-49cf-b27d-23a0a2ed3e7b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -192
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "content": "## Schedule and configure\n\nFires every morning at 8AM and loops through your list of competitors. All settings -- URLs, company name, email recipient -- live in the Configure node so you only ever need to edit one place."
      },
      "typeVersion": 1
    },
    {
      "id": "9a0d9a0c-3154-439b-afdd-d4ca5ced8baf",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        -192
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "content": "## Fetch, clean and analyse each competitor\n\nVisits each competitor URL, strips the HTML down to readable text, then sends it to GPT-4o-mini to extract key signals, threat level, and a recommended action. Runs once per competitor in parallel."
      },
      "typeVersion": 1
    },
    {
      "id": "82e9fb55-a558-42e5-b6cf-62d07ecf1064",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2752,
        -336
      ],
      "parameters": {
        "color": 7,
        "width": 720,
        "content": "## Compile, email and log\n\nAggregates all competitor analyses into a single prompt for GPT-4o, which writes the final executive briefing. The briefing is formatted as a clean HTML email, sent to your team, and logged to Google Sheets."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "3e1723ae-41ea-4b98-ab64-53dcc5ba2f65",
  "connections": {
    "Daily 8AM Trigger": {
      "main": [
        [
          {
            "node": "Configure Competitors and Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format HTML Email": {
      "main": [
        [
          {
            "node": "Send Email Briefing",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Aggregate and Build Briefing Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Analyze Competitor": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Competitor Page": {
      "main": [
        [
          {
            "node": "Extract Text and Build AI Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Generate Final Briefing": {
      "main": [
        [
          {
            "node": "Format HTML Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text and Build AI Prompt": {
      "main": [
        [
          {
            "node": "AI Analyze Competitor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Competitors and Settings": {
      "main": [
        [
          {
            "node": "Fetch Competitor Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate and Build Briefing Prompt": {
      "main": [
        [
          {
            "node": "AI Generate Final Briefing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}