{
  "name": "Weekly Competitor Intelligence Digest — Competitor Pulse + AI + Slack + Email",
  "meta": {
    "instanceId": "noniner-template-competitor-intelligence-v2",
    "templateCredsSetupCompleted": false
  },
  "description": "Runs every Monday morning: scrapes up to 5 competitor domains with No Niner's Competitor Pulse actor, uses GPT-4o-mini to write an executive brief, sends a Slack alert if critical changes are found, logs everything to Google Sheets, and emails a weekly digest. Zero manual work once set up.",
  "nodes": [
    {
      "id": "sticky-overview",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-260, 60],
      "parameters": {
        "content": "## Weekly Competitor Intelligence Digest\n\n**What it does**\nEvery Monday at 8 AM this workflow:\n1. Runs No Niner's Competitor Pulse actor on your competitor list\n2. Detects pricing changes, new features and messaging shifts\n3. Sends a Slack alert if critical changes are found\n4. Writes an AI-generated executive brief with GPT-4o-mini\n5. Logs the digest to a Google Sheets tab\n6. Emails the weekly digest to your inbox\n\n**Setup (5 min)**\n- `Apify Token` — get a free token at apify.com/sign-up\n- `OpenAI API key` — platform.openai.com\n- `Slack credential` — set up OAuth or Incoming Webhook\n- `Gmail OAuth` — connect your Google account\n- `Google Sheets` — create a sheet and paste the ID\n\n**Customise**\nEdit the *Configure* node to change competitor domains, Slack channel and notification email.",
        "width": 440,
        "height": 760,
        "color": 5
      }
    },
    {
      "id": "sticky-trigger",
      "name": "Sticky Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [300, 60],
      "parameters": {
        "content": "**Step 1 — Trigger**\nRuns every Monday at 8 AM.\nChange the schedule in the trigger node.",
        "width": 240,
        "height": 120,
        "color": 7
      }
    },
    {
      "id": "sticky-scrape",
      "name": "Sticky Scrape",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [780, 60],
      "parameters": {
        "content": "**Step 2 — Scrape competitors**\nNo Niner's Competitor Pulse runs on Apify and returns structured change data: pricing, features, messaging, job postings.\n\nRequires an Apify token (free tier available).",
        "width": 240,
        "height": 160,
        "color": 7
      }
    },
    {
      "id": "sticky-notify",
      "name": "Sticky Notify",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [1300, 60],
      "parameters": {
        "content": "**Step 3 — Alert + Report**\nIf a critical change is detected (pricing, new feature or major messaging shift) a Slack alert fires immediately.\n\nWhether or not there are critical changes, an AI digest is sent by email and logged to Sheets.",
        "width": 240,
        "height": 180,
        "color": 7
      }
    },
    {
      "id": "schedule-trigger",
      "name": "Every Monday 8am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [320, 300],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      }
    },
    {
      "id": "set-config",
      "name": "Configure",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [540, 300],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "comp-domains",
              "name": "competitor_domains",
              "value": "[\"competitor1.com\", \"competitor2.com\", \"competitor3.com\"]",
              "type": "string"
            },
            {
              "id": "notify-email",
              "name": "notify_email",
              "value": "you@company.com",
              "type": "string"
            },
            {
              "id": "slack-channel",
              "name": "slack_channel",
              "value": "#competitive-intel",
              "type": "string"
            },
            {
              "id": "sheets-id",
              "name": "sheets_id",
              "value": "YOUR_GOOGLE_SHEET_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "http-run-competitor-pulse",
      "name": "Run Competitor Pulse",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [780, 300],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/noniner~competitor-pulse/run-sync-get-dataset-items",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            { "name": "token", "value": "={{ $credentials.apifyApiToken }}" },
            { "name": "timeout", "value": "120" },
            { "name": "maxItems", "value": "50" }
          ]
        },
        "contentType": "json",
        "body": {
          "domains": "={{ JSON.parse($json.competitor_domains) }}",
          "trackContent": true,
          "trackPricing": true,
          "trackJobPostings": true,
          "trackNewFeatures": true
        },
        "options": {}
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "apify-token",
          "name": "Apify Token"
        }
      }
    },
    {
      "id": "code-detect-changes",
      "name": "Detect Critical Changes",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1000, 300],
      "parameters": {
        "jsCode": "// Inspect the Competitor Pulse results and flag critical changes.\n// Critical = pricing change, new feature launch, or major homepage shift.\nconst items = $input.all();\nconst changes = items.map(i => i.json);\n\nconst critical = changes.filter(c =>\n  c.pricingChanged === true ||\n  c.newFeatureDetected === true ||\n  c.homepageChangePct > 40\n);\n\nconst summaryLines = changes.map(c =>\n  `• ${c.domain || 'unknown'}: ${c.summary || 'no summary'}`\n).join('\\n');\n\nreturn [{\n  json: {\n    allChanges: changes,\n    criticalChanges: critical,\n    hasCritical: critical.length > 0,\n    changeCount: changes.length,\n    summaryText: summaryLines || 'No changes detected this week.',\n    runDate: new Date().toISOString().split('T')[0]\n  }\n}];"
      }
    },
    {
      "id": "if-critical",
      "name": "Critical Changes?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1220, 300],
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            {
              "id": "cond-critical",
              "leftValue": "={{ $json.hasCritical }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "slack-alert",
      "name": "Slack Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [1440, 140],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "channel": "={{ $('Configure').item.json.slack_channel }}",
        "text": ":rotating_light: *Competitor alert — {{ $json.runDate }}*\n\n{{ $json.criticalChanges.map(c => `*${c.domain}*: ${c.summary}`).join('\\n') }}\n\nFull digest coming by email.",
        "otherOptions": {}
      }
    },
    {
      "id": "noop-no-changes",
      "name": "No Critical Changes",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1440, 460]
    },
    {
      "id": "merge-branches",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [1660, 300],
      "parameters": {
        "mode": "chooseBranch",
        "chooseBranchMode": "waitForAll"
      }
    },
    {
      "id": "openai-summary",
      "name": "AI Executive Brief",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [1880, 300],
      "parameters": {
        "resource": "chat",
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a competitive intelligence analyst. Write a crisp weekly executive brief (max 300 words) based on the competitor change data provided. Organise by company. Lead with the most strategically important changes. Use clear bullet points. Flag pricing changes and new feature launches prominently."
            },
            {
              "role": "user",
              "content": "Date: {{ $('Detect Critical Changes').item.json.runDate }}\n\nCompetitor changes this week:\n{{ $('Detect Critical Changes').item.json.summaryText }}\n\nFull data:\n{{ JSON.stringify($('Detect Critical Changes').item.json.allChanges, null, 2) }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "openai-key",
          "name": "OpenAI"
        }
      }
    },
    {
      "id": "sheets-log",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [2100, 300],
      "parameters": {
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Configure').first().json.sheets_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Weekly Digest"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $('Detect Critical Changes').item.json.runDate }}",
            "Changes Detected": "={{ $('Detect Critical Changes').item.json.changeCount }}",
            "Critical Changes": "={{ $('Detect Critical Changes').item.json.criticalChanges.length }}",
            "AI Brief": "={{ $json.choices[0].message.content }}",
            "Raw Summary": "={{ $('Detect Critical Changes').item.json.summaryText }}"
          }
        },
        "options": {}
      }
    },
    {
      "id": "gmail-digest",
      "name": "Email Weekly Digest",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [2320, 300],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Configure').first().json.notify_email }}",
        "subject": "Competitor Intelligence Brief — {{ $('Detect Critical Changes').item.json.runDate }}",
        "emailType": "text",
        "message": "Weekly Competitor Intelligence Brief\n{{ $('Detect Critical Changes').item.json.runDate }}\n\n{{ $json.choices[0].message.content }}\n\n---\nChange count this week: {{ $('Detect Critical Changes').item.json.changeCount }}\nCritical changes: {{ $('Detect Critical Changes').item.json.criticalChanges.length }}\n\nFull log in Google Sheets.\n\nPowered by No Niner Competitor Pulse — noniner.io",
        "options": {}
      }
    }
  ],
  "connections": {
    "Every Monday 8am": {
      "main": [[{ "node": "Configure", "type": "main", "index": 0 }]]
    },
    "Configure": {
      "main": [[{ "node": "Run Competitor Pulse", "type": "main", "index": 0 }]]
    },
    "Run Competitor Pulse": {
      "main": [[{ "node": "Detect Critical Changes", "type": "main", "index": 0 }]]
    },
    "Detect Critical Changes": {
      "main": [[{ "node": "Critical Changes?", "type": "main", "index": 0 }]]
    },
    "Critical Changes?": {
      "main": [
        [{ "node": "Slack Alert", "type": "main", "index": 0 }],
        [{ "node": "No Critical Changes", "type": "main", "index": 0 }]
      ]
    },
    "Slack Alert": {
      "main": [[{ "node": "Merge", "type": "main", "index": 0 }]]
    },
    "No Critical Changes": {
      "main": [[{ "node": "Merge", "type": "main", "index": 1 }]]
    },
    "Merge": {
      "main": [[{ "node": "AI Executive Brief", "type": "main", "index": 0 }]]
    },
    "AI Executive Brief": {
      "main": [[{ "node": "Log to Google Sheets", "type": "main", "index": 0 }]]
    },
    "Log to Google Sheets": {
      "main": [[{ "node": "Email Weekly Digest", "type": "main", "index": 0 }]]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null
}
