{
  "name": "Vorlux AI | Cross-Platform Recap",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      },
      "id": "cron",
      "name": "Daily at Midnight",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{$env.VORLUX_HUB_URL}}/api/analytics/daily?platforms=twitch,youtube,twitter,discord",
        "options": {
          "timeout": 15000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "vorlux_hub={\"v\":3,\"ts\":1774181154534,\"uid\":\"admin\",\"role\":\"super_admin\",\"tier\":\"partner\",\"exp\":1805717154534,\"authMethod\":\"api\"}.a2d82bd0cfaaee6babff9174193f0fbce06fab372a741e7ad96b59655090a92f"
            }
          ]
        }
      },
      "id": "fetch-stats",
      "name": "Fetch Platform Stats",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        300
      ],
      "notes": "Gets daily metrics from all connected platforms"
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const stats = $input.first().json.data || {};\nconst twitch = stats.twitch || { viewers: 0, followers: 0, hours: 0 };\nconst youtube = stats.youtube || { views: 0, subs: 0, likes: 0 };\nconst twitter = stats.twitter || { impressions: 0, followers: 0, engagement: 0 };\nconst discord = stats.discord || { members: 0, messages: 0, active: 0 };\nconst totalReach = twitch.viewers + youtube.views + twitter.impressions;\nconst recap = {\n  date: new Date().toISOString().split('T')[0],\n  platforms: { twitch, youtube, twitter, discord },\n  totalReach,\n  highlights: []\n};\nif (twitch.viewers > 50) recap.highlights.push(`Twitch peaked at ${twitch.viewers} viewers`);\nif (youtube.views > 100) recap.highlights.push(`YouTube hit ${youtube.views} views`);\nif (discord.messages > 200) recap.highlights.push(`Discord had ${discord.messages} messages`);\nconst embed = { embeds: [{\n  title: `\ud83d\udcca Daily Recap \u2014 ${recap.date}`,\n  color: 5793266,\n  fields: [\n    { name: '\ud83d\udfe3 Twitch', value: `${twitch.viewers} viewers | ${twitch.followers} new follows | ${twitch.hours}h streamed`, inline: false },\n    { name: '\ud83d\udd34 YouTube', value: `${youtube.views} views | ${youtube.subs} new subs | ${youtube.likes} likes`, inline: false },\n    { name: '\ud83d\udc26 Twitter', value: `${twitter.impressions} impressions | ${twitter.followers} new followers`, inline: false },\n    { name: '\ud83d\udcac Discord', value: `${discord.members} members | ${discord.messages} messages | ${discord.active} active`, inline: false },\n    { name: '\ud83c\udf10 Total Reach', value: `${totalReach.toLocaleString()} people`, inline: true }\n  ],\n  footer: { text: 'Vorlux AI HUB Daily Recap' },\n  timestamp: new Date().toISOString()\n}] };\nreturn [{ json: { recap, embed } }];"
      },
      "id": "build-recap",
      "name": "Build Recap",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        680,
        300
      ],
      "notes": "Aggregates all platform stats into a unified daily recap"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_RECAP_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.embed) }}",
        "options": {
          "timeout": 10000
        }
      },
      "id": "post-discord",
      "name": "Post to Discord",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/analytics/daily",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.recap) }}",
        "options": {
          "timeout": 10000
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "vorlux_hub={\"v\":3,\"ts\":1774181154534,\"uid\":\"admin\",\"role\":\"super_admin\",\"tier\":\"partner\",\"exp\":1805717154534,\"authMethod\":\"api\"}.a2d82bd0cfaaee6babff9174193f0fbce06fab372a741e7ad96b59655090a92f"
            }
          ]
        }
      },
      "id": "save-hub",
      "name": "Save to Hub",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        920,
        400
      ]
    }
  ],
  "connections": {
    "Daily at Midnight": {
      "main": [
        [
          {
            "node": "Fetch Platform Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Platform Stats": {
      "main": [
        [
          {
            "node": "Build Recap",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Recap": {
      "main": [
        [
          {
            "node": "Post to Discord",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save to Hub",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  }
}