{
  "name": "Daily YouTube Outlier Alert Bot (OutlierKit → Slack)",
  "nodes": [
    {
      "parameters": {
        "content": "## 🚨 Daily YouTube Outlier Alert Bot\n\nEvery morning, scans your niche with the **OutlierKit API** for videos massively over-performing their channel's average, and posts a ranked digest to **Slack** — so your team can jump on trending topics while they're still hot.\n\n### Setup (3 minutes)\n1. **OutlierKit API key** — Pro or Max plan → dashboard → Settings → API. Docs: https://outlierkit.com/app/api-docs\n2. On the HTTP Request node, create a **Header Auth** credential:\n   - Name: `Authorization`\n   - Value: `Bearer YOUR_OUTLIERKIT_API_KEY`\n3. Connect your **Slack** credential and pick a channel on the *Send Slack Alert* node (or swap in Discord / Telegram / Email).\n4. Edit **Alert Settings** with your niche and thresholds, then hit *Execute workflow*.\n\n💳 Cost per run: 1 OutlierKit credit (~30/month on the daily schedule).\n\nGuide: https://outlierkit.com/resources/n8n-outlier-alert-template/",
        "height": 560,
        "width": 420
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000001",
      "name": "Sticky Note — Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-860, 140]
    },
    {
      "parameters": {
        "content": "### How the scoring works\n\n`POST /api/v1/outliers/search` runs a semantic search across indexed videos and returns each one's **outlier score** — a multiple of its channel's average views. A 10x score means the video did 10x better than that channel normally does: proven, fresh demand.\n\nTune `minOutlierScore` and `minViews` in **Alert Settings** to control alert volume.",
        "height": 320,
        "width": 400,
        "color": 5
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000002",
      "name": "Sticky Note — Scoring",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-140, 140]
    },
    {
      "parameters": {},
      "id": "a3b9d4f2-2222-4b02-8d02-000000000010",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [-640, 620]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000011",
      "name": "Every Day 8 AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [-640, 460]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "niche-assignment",
              "name": "niche",
              "value": "space facts",
              "type": "string"
            },
            {
              "id": "score-assignment",
              "name": "minOutlierScore",
              "value": 10,
              "type": "number"
            },
            {
              "id": "views-assignment",
              "name": "minViews",
              "value": 50000,
              "type": "number"
            },
            {
              "id": "limit-assignment",
              "name": "maxResults",
              "value": 10,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000012",
      "name": "Alert Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [-400, 540]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://outlierkit.com/api/v1/outliers/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"query\": \"{{ $json.niche }}\",\n  \"limit\": {{ $json.maxResults }},\n  \"minOutlierScore\": {{ $json.minOutlierScore }}\n}",
        "options": {}
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000013",
      "name": "Find Outlier Videos (OutlierKit)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [-140, 540]
    },
    {
      "parameters": {
        "jsCode": "// Unwrap the API envelope, apply the view floor, rank by outlier\n// score, and build one Slack-ready digest message.\n// Returns no items when nothing clears the bar, so no empty alerts.\nconst settings = $('Alert Settings').first().json;\nconst payload = $input.first().json;\nconst data = payload.data ?? payload;\nlet results = Array.isArray(data.results) ? data.results : [];\n\nresults = results.filter((v) => (v.views ?? 0) >= (settings.minViews ?? 0));\nresults.sort(\n  (a, b) =>\n    (b.highestValue ?? b.outlierScore ?? 0) -\n    (a.highestValue ?? a.outlierScore ?? 0),\n);\n\nif (results.length === 0) {\n  return [];\n}\n\nconst lines = results.map((v) => {\n  const id = v.id ?? v.videoId ?? '';\n  const score = v.highestValue ?? v.outlierScore ?? 0;\n  const channel =\n    typeof v.channel === 'object' && v.channel !== null\n      ? v.channel.title\n      : v.channel;\n  const views = (v.views ?? 0).toLocaleString('en-US');\n  return `• *${v.title}* — ${score}x outlier, ${views} views (${channel})\\n   https://www.youtube.com/watch?v=${id}`;\n});\n\nconst digest = [\n  `:rotating_light: *${results.length} outlier video${results.length === 1 ? '' : 's'} detected in \"${settings.niche}\"*`,\n  '',\n  ...lines,\n  '',\n  `_Scores are multiples of each channel's average views — via the OutlierKit API._`,\n].join('\\n');\n\nreturn [{ json: { digest, count: results.length } }];"
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000014",
      "name": "Build Alert Digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [100, 540]
    },
    {
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "text": "={{ $json.digest }}",
        "otherOptions": {}
      },
      "id": "a3b9d4f2-2222-4b02-8d02-000000000015",
      "name": "Send Slack Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [340, 540]
    }
  ],
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Alert Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Day 8 AM": {
      "main": [
        [
          {
            "node": "Alert Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert Settings": {
      "main": [
        [
          {
            "node": "Find Outlier Videos (OutlierKit)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Outlier Videos (OutlierKit)": {
      "main": [
        [
          {
            "node": "Build Alert Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Alert Digest": {
      "main": [
        [
          {
            "node": "Send Slack Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
