{
  "name": "Vorlux AI | Hacker News \u2192 Content Pipeline",
  "nodes": [
    {
      "id": "e0ce94f7-ff3d-422a-a13a-92078d4c3a27",
      "name": "Every 4 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 4
            }
          ]
        }
      }
    },
    {
      "id": "6d704d9a-f6b3-4566-b3c9-3bb5d3bf035e",
      "name": "Fetch HN Front Page",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty",
        "options": {
          "timeout": 10000
        }
      },
      "notes": "Gets top 500 HN story IDs from Firebase API"
    },
    {
      "id": "1d76b54f-8cab-4354-b6ef-fd8ffecde4d6",
      "name": "Get Top Stories",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const ids = $input.first().json || [];\nconst topIds = ids.slice(0, 15);\nconst stories = [];\nfor (const id of topIds) {\n  try {\n    const res = await fetch('https://hacker-news.firebaseio.com/v0/item/' + id + '.json');\n    const story = await res.json();\n    if (story && story.score > 50 && story.type === 'story') {\n      stories.push({\n        hnId: story.id,\n        title: story.title,\n        url: story.url || 'https://news.ycombinator.com/item?id=' + story.id,\n        score: story.score,\n        comments: story.descendants || 0,\n        by: story.by\n      });\n    }\n  } catch {}\n}\n// Filter for tech-relevant stories\nconst techKeywords = /ai|ml|gpu|streaming|react|next|rust|python|open.source|llm|model|api|cloud|dev|code|startup/i;\nconst relevant = stories.filter(s => techKeywords.test(s.title));\nreturn [{json: {stories: relevant.slice(0, 5), total: stories.length, relevant: relevant.length}}];"
      },
      "notes": "Fetches story details, filters for tech-relevant (score>50)"
    },
    {
      "id": "21240c87-86d0-48a7-9047-a8d60ecdb80a",
      "name": "Check Duplicates",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/content/topics/check-duplicates",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({titles: $json.stories.map(s => s.title)}) }}",
        "options": {
          "timeout": 15000
        }
      },
      "notes": "Checks against existing topics to avoid duplicates"
    },
    {
      "id": "1d2757bc-f53d-49cf-9e0f-2ebdb4e7c43e",
      "name": "Create Topics",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/content/topics/batch",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({topics: $json.stories.map(s => ({title: s.title, url: s.url, source: \"hackernews\", relevance: Math.min(10, Math.round(s.score / 50)), metadata: {hnScore: s.score, comments: s.comments}}))}) }}",
        "options": {
          "timeout": 15000
        }
      },
      "notes": "Creates topic entries from HN stories"
    },
    {
      "id": "f31ea69f-3c07-4813-b236-e33a0e201e18",
      "name": "Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"\ud83d\udd25 HN Trending: {{ $json.relevant }} relevant stories\",\"description\":\"{{ $json.stories.slice(0,3).map(s => \"\u2022 [\" + s.score + \"] \" + s.title).join(\"\\\\n\") }}\",\"color\":16753920,\"footer\":{\"text\":\"Hacker News \u2192 Vorlux AI Pipeline\"}}]}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Every 4 Hours": {
      "main": [
        [
          {
            "node": "Fetch HN Front Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch HN Front Page": {
      "main": [
        [
          {
            "node": "Get Top Stories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Top Stories": {
      "main": [
        [
          {
            "node": "Check Duplicates",
            "type": "main",
            "index": 0
          },
          {
            "node": "Create Topics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Topics": {
      "main": [
        [
          {
            "node": "Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}