{
  "name": "Vorlux AI | Social Media Auto-Amplifier",
  "nodes": [
    {
      "id": "6d6a4bd8-fde8-4513-b19a-6485fadd9367",
      "name": "Every 3 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 3
            }
          ]
        }
      }
    },
    {
      "id": "049fc69c-a662-4b4b-8a90-1a986d6c35f4",
      "name": "Fetch Trending",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Scrape trending topics from multiple sources\nconst hubUrl = $env.VORLUX_HUB_URL || 'http://localhost:3010';\nconst sources = [];\n\n// Get our recent published content\ntry {\n  const res = await fetch(hubUrl + '/api/blog/posts?status=published&limit=5&period=3d');\n  const posts = (await res.json()).data || [];\n  sources.push(...posts.map(p => ({type: 'own_content', title: p.title, url: '/blog/' + p.slug, excerpt: (p.excerpt || '').substring(0, 200)})));\n} catch {}\n\n// Get HN trending (tech relevance)\ntry {\n  const res = await fetch('https://hacker-news.firebaseio.com/v0/topstories.json');\n  const ids = (await res.json()).slice(0, 5);\n  for (const id of ids) {\n    const storyRes = await fetch('https://hacker-news.firebaseio.com/v0/item/' + id + '.json');\n    const story = await storyRes.json();\n    if (story.score > 100) {\n      sources.push({type: 'trending', title: story.title, url: story.url, score: story.score});\n    }\n  }\n} catch {}\n\nreturn [{json: {sources, ownContent: sources.filter(s => s.type === 'own_content').length, trending: sources.filter(s => s.type === 'trending').length}}];"
      },
      "notes": "Aggregates our content + HN trending for social posts"
    },
    {
      "id": "4185c139-7905-4e4f-b23e-8d31b083f916",
      "name": "Generate Posts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/orchestrator/execute",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"agentId\":\"social-media-agent\",\"action\":\"generate_social_posts\",\"params\":{\"sources\":{{ JSON.stringify($json.sources.slice(0, 5)) }},\"platforms\":[\"twitter\",\"discord\",\"linkedin\"],\"tone\":\"tech-savvy, approachable, enthusiastic\",\"brand\":\"Vorlux AI HUB\"}}",
        "options": {
          "timeout": 60000
        }
      },
      "notes": "AI generates platform-specific posts from source material"
    },
    {
      "id": "662a1536-0985-431b-9f97-b85868d7cacd",
      "name": "Parse & Schedule",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        940,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const result = $input.first().json.data?.result || '';\n// Try to parse AI-generated posts\nlet posts = [];\ntry {\n  const match = result.match(/\\{[\\s\\S]*\\}/);\n  if (match) posts = JSON.parse(match[0]).posts || [];\n} catch {}\n\nif (!posts.length) {\n  // Fallback: create posts from sources\n  const sources = $node['Fetch Trending'].json.sources || [];\n  for (const s of sources.slice(0, 3)) {\n    posts.push({platform: 'twitter', content: s.title + '\\n\\n' + (s.excerpt || '') + '\\n\\n' + (s.url || '') + '\\n\\n#Vorlux AI #Tech'});\n    posts.push({platform: 'discord', content: JSON.stringify({embeds: [{title: s.title, description: s.excerpt || '', color: 5793266}]})});\n  }\n}\n\n// Schedule posts with 1h gaps\nconst scheduledPosts = posts.map((p, i) => ({\n  ...p,\n  scheduledAt: new Date(Date.now() + (i + 1) * 3600000).toISOString()\n}));\n\nreturn [{json: {posts: scheduledPosts, count: scheduledPosts.length}}];"
      },
      "notes": "Parses AI output and schedules posts with time gaps"
    },
    {
      "id": "1d565f7b-2b27-487e-a9e7-0ec3e276dd6e",
      "name": "Queue Posts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/social/schedule",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({posts: $json.posts}) }}",
        "options": {
          "timeout": 15000
        }
      }
    },
    {
      "id": "54d6c1c9-63d2-4a6a-9d01-52ab46697bbb",
      "name": "Report",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1180,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_OPS_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"\ud83d\udce2 Social Amplifier: {{ $json.count }} posts scheduled\",\"description\":\"From {{ $node[\"Fetch Trending\"].json.ownContent }} own articles + {{ $node[\"Fetch Trending\"].json.trending }} trending topics\",\"color\":5793266}]}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Every 3 Hours": {
      "main": [
        [
          {
            "node": "Fetch Trending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Trending": {
      "main": [
        [
          {
            "node": "Generate Posts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Posts": {
      "main": [
        [
          {
            "node": "Parse & Schedule",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse & Schedule": {
      "main": [
        [
          {
            "node": "Queue Posts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}