{
  "name": "AI Competitive Intelligence Agent",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "weeksInterval": 1
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -800,
        0
      ],
      "id": "schedule-trigger",
      "name": "Schedule: Run Every Monday"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "competitors-list",
              "name": "competitors",
              "value": "=[\"OpenAI\", \"Anthropic\", \"Google DeepMind\", \"Mistral AI\", \"Cohere\"]",
              "type": "array"
            },
            {
              "id": "your-company",
              "name": "your_company",
              "value": "Your Company Name",
              "type": "string"
            },
            {
              "id": "industry",
              "name": "industry",
              "value": "AI/ML SaaS",
              "type": "string"
            },
            {
              "id": "report-date",
              "name": "report_date",
              "value": "={{ $now.format('MMMM D, YYYY') }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -600,
        0
      ],
      "id": "set-config",
      "name": "Configure Competitors"
    },
    {
      "parameters": {
        "url": "=https://serpapi.com/search.json?q={{ encodeURIComponent($json.competitors[0] + ' news product update 2025') }}&api_key=YOUR_SERPAPI_KEY&num=5",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        -300
      ],
      "id": "search-comp-1",
      "name": "Search Competitor 1 News"
    },
    {
      "parameters": {
        "url": "=https://serpapi.com/search.json?q={{ encodeURIComponent($('Configure Competitors').item.json.competitors[1] + ' news product update 2025') }}&api_key=YOUR_SERPAPI_KEY&num=5",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        -150
      ],
      "id": "search-comp-2",
      "name": "Search Competitor 2 News"
    },
    {
      "parameters": {
        "url": "=https://serpapi.com/search.json?q={{ encodeURIComponent($('Configure Competitors').item.json.competitors[2] + ' news product update 2025') }}&api_key=YOUR_SERPAPI_KEY&num=5",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        0
      ],
      "id": "search-comp-3",
      "name": "Search Competitor 3 News"
    },
    {
      "parameters": {
        "url": "=https://serpapi.com/search.json?q={{ encodeURIComponent($('Configure Competitors').item.json.competitors[3] + ' news product update 2025') }}&api_key=YOUR_SERPAPI_KEY&num=5",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        150
      ],
      "id": "search-comp-4",
      "name": "Search Competitor 4 News"
    },
    {
      "parameters": {
        "url": "=https://serpapi.com/search.json?q={{ encodeURIComponent($('Configure Competitors').item.json.competitors[4] + ' news product update 2025') }}&api_key=YOUR_SERPAPI_KEY&num=5",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -400,
        300
      ],
      "id": "search-comp-5",
      "name": "Search Competitor 5 News"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"raw_results\": {\n    \"comp1\": {{ JSON.stringify($('Search Competitor 1 News').item.json.organic_results || []) }},\n    \"comp2\": {{ JSON.stringify($('Search Competitor 2 News').item.json.organic_results || []) }},\n    \"comp3\": {{ JSON.stringify($('Search Competitor 3 News').item.json.organic_results || []) }},\n    \"comp4\": {{ JSON.stringify($('Search Competitor 4 News').item.json.organic_results || []) }},\n    \"comp5\": {{ JSON.stringify($('Search Competitor 5 News').item.json.organic_results || []) }}\n  },\n  \"competitors\": {{ JSON.stringify($('Configure Competitors').item.json.competitors) }},\n  \"your_company\": \"{{ $('Configure Competitors').item.json.your_company }}\",\n  \"report_date\": \"{{ $('Configure Competitors').item.json.report_date }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -100,
        0
      ],
      "id": "merge-results",
      "name": "Merge Search Results"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4o",
          "mode": "list",
          "cachedResultName": "GPT-4O"
        },
        "responses": {
          "values": [
            {
              "role": "system",
              "content": "You are a senior business intelligence analyst specializing in competitive analysis. Analyze the provided competitor news and return ONLY valid JSON:\n{\n  \"executive_summary\": \"2-3 paragraph overview of the competitive landscape this week\",\n  \"key_threats\": [\n    {\"competitor\": \"\", \"threat\": \"\", \"severity\": \"High/Medium/Low\", \"recommended_response\": \"\"}\n  ],\n  \"key_opportunities\": [\n    {\"opportunity\": \"\", \"rationale\": \"\", \"action\": \"\"}\n  ],\n  \"competitor_updates\": [\n    {\"company\": \"\", \"update\": \"\", \"impact\": \"\", \"source\": \"\"}\n  ],\n  \"market_trends\": [],\n  \"recommended_actions\": [],\n  \"alert_level\": \"Low/Medium/High/Critical\"\n}"
            },
            {
              "content": "=Analyze this competitive intelligence data for week of {{ $json.report_date }}.\n\nOur company: {{ $json.your_company }}\nIndustry: AI/ML SaaS\n\nCompetitor news found:\n\nComp 1 ({{ $json.competitors[0] }}):\n{{ JSON.stringify($json.raw_results.comp1.slice(0,3).map(r => r.title + ': ' + r.snippet)) }}\n\nComp 2 ({{ $json.competitors[1] }}):\n{{ JSON.stringify($json.raw_results.comp2.slice(0,3).map(r => r.title + ': ' + r.snippet)) }}\n\nComp 3 ({{ $json.competitors[2] }}):\n{{ JSON.stringify($json.raw_results.comp3.slice(0,3).map(r => r.title + ': ' + r.snippet)) }}\n\nComp 4 ({{ $json.competitors[3] }}):\n{{ JSON.stringify($json.raw_results.comp4.slice(0,3).map(r => r.title + ': ' + r.snippet)) }}\n\nComp 5 ({{ $json.competitors[4] }}):\n{{ JSON.stringify($json.raw_results.comp5.slice(0,3).map(r => r.title + ': ' + r.snippet)) }}"
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 2,
      "position": [
        150,
        0
      ],
      "id": "analyze-intelligence",
      "name": "GPT-4o: Analyze Intelligence"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "parse-report",
              "name": "report",
              "value": "={{ JSON.parse($json.output[0].content[0].text) }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        380,
        0
      ],
      "id": "parse-report",
      "name": "Parse Intelligence Report"
    },
    {
      "parameters": {
        "sendTo": "team@yourcompany.com",
        "subject": "=\ud83d\udd0d Weekly Competitive Intelligence Report \u2014 {{ $('Configure Competitors').item.json.report_date }}",
        "emailType": "html",
        "message": "=<div style='font-family: Arial, sans-serif; max-width: 700px; margin: 0 auto;'>\n<h1 style='color: #1a1a2e; border-bottom: 3px solid #e94560; padding-bottom: 10px;'>\ud83d\udd0d Weekly Competitive Intelligence Report</h1>\n<p style='color: #666;'>Week of {{ $('Configure Competitors').item.json.report_date }}</p>\n\n<div style='background: {{ $json.report.alert_level === \"Critical\" ? \"#fee\" : $json.report.alert_level === \"High\" ? \"#fff3e0\" : \"#e8f5e9\" }}; padding: 15px; border-radius: 8px; margin: 20px 0;'>\n<strong>Alert Level: {{ $json.report.alert_level }}</strong>\n</div>\n\n<h2>\ud83d\udccb Executive Summary</h2>\n<p>{{ $json.report.executive_summary }}</p>\n\n<h2>\u26a0\ufe0f Key Threats</h2>\n{{ $json.report.key_threats.map(t => '<div style=\"background:#fff8e1;padding:12px;margin:8px 0;border-left:4px solid #ffa000;border-radius:4px;\"><strong>' + t.competitor + '</strong> [' + t.severity + ']<br/>' + t.threat + '<br/><em>Response: ' + t.recommended_response + '</em></div>').join('') }}\n\n<h2>\ud83d\udca1 Opportunities</h2>\n{{ $json.report.key_opportunities.map(o => '<div style=\"background:#e8f5e9;padding:12px;margin:8px 0;border-left:4px solid #43a047;border-radius:4px;\">' + o.opportunity + '<br/><em>Action: ' + o.action + '</em></div>').join('') }}\n\n<h2>\ud83d\udcf0 Competitor Updates</h2>\n{{ $json.report.competitor_updates.map(u => '<div style=\"padding:10px;border-bottom:1px solid #eee;\"><strong>' + u.company + ':</strong> ' + u.update + '<br/><small style=\"color:#666;\">Impact: ' + u.impact + '</small></div>').join('') }}\n\n<h2>\u2705 Recommended Actions</h2>\n<ul>{{ $json.report.recommended_actions.map(a => '<li>' + a + '</li>').join('') }}</ul>\n\n<p style='color:#999; font-size:12px; margin-top:30px;'>Generated automatically by AI Competitive Intelligence Agent</p>\n</div>",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        600,
        -150
      ],
      "id": "send-email-report",
      "name": "Email Report to Team"
    },
    {
      "parameters": {
        "channel": "competitive-intel",
        "text": "=\ud83d\udd0d *Weekly Competitive Intelligence Report* \u2014 {{ $('Configure Competitors').item.json.report_date }}\n\n*Alert Level:* {{ $('Parse Intelligence Report').item.json.report.alert_level }}\n\n*Executive Summary:*\n{{ $('Parse Intelligence Report').item.json.report.executive_summary.substring(0, 300) }}...\n\n*Top Threats:*\n{{ $('Parse Intelligence Report').item.json.report.key_threats.slice(0,3).map(t => '\u2022 ' + t.competitor + ': ' + t.threat.substring(0,80) + '...').join('\\n') }}\n\n*Opportunities:*\n{{ $('Parse Intelligence Report').item.json.report.key_opportunities.slice(0,2).map(o => '\u2022 ' + o.opportunity.substring(0,80)).join('\\n') }}\n\n_Full report sent to team email_ \ud83d\udce7",
        "otherOptions": {}
      },
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        600,
        150
      ],
      "id": "slack-summary",
      "name": "Slack Summary to Team"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Intelligence Log",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "report_date": "={{ $('Configure Competitors').item.json.report_date }}",
            "alert_level": "={{ $('Parse Intelligence Report').item.json.report.alert_level }}",
            "executive_summary": "={{ $('Parse Intelligence Report').item.json.report.executive_summary.substring(0, 500) }}",
            "top_threat": "={{ $('Parse Intelligence Report').item.json.report.key_threats[0].threat }}",
            "top_opportunity": "={{ $('Parse Intelligence Report').item.json.report.key_opportunities[0].opportunity }}",
            "recommended_actions_count": "={{ $('Parse Intelligence Report').item.json.report.recommended_actions.length }}"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        850,
        0
      ],
      "id": "log-report",
      "name": "Archive to Google Sheets"
    }
  ],
  "connections": {
    "Schedule: Run Every Monday": {
      "main": [
        [
          {
            "node": "Configure Competitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Competitors": {
      "main": [
        [
          {
            "node": "Search Competitor 1 News",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Competitor 2 News",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Competitor 3 News",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Competitor 4 News",
            "type": "main",
            "index": 0
          },
          {
            "node": "Search Competitor 5 News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Competitor 1 News": {
      "main": [
        [
          {
            "node": "Merge Search Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Competitor 2 News": {
      "main": [
        [
          {
            "node": "Merge Search Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Search Competitor 3 News": {
      "main": [
        [
          {
            "node": "Merge Search Results",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Search Competitor 4 News": {
      "main": [
        [
          {
            "node": "Merge Search Results",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Search Competitor 5 News": {
      "main": [
        [
          {
            "node": "Merge Search Results",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "Merge Search Results": {
      "main": [
        [
          {
            "node": "GPT-4o: Analyze Intelligence",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o: Analyze Intelligence": {
      "main": [
        [
          {
            "node": "Parse Intelligence Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Intelligence Report": {
      "main": [
        [
          {
            "node": "Email Report to Team",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack Summary to Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Report to Team": {
      "main": [
        [
          {
            "node": "Archive to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack Summary to Team": {
      "main": [
        [
          {
            "node": "Archive to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    "competitive-intelligence",
    "ai-agent",
    "automation",
    "business-intelligence"
  ]
}