{
  "name": "Vorlux AI | Discord Activity Report",
  "active": false,
  "nodes": [
    {
      "parameters": { "rule": { "interval": [{ "field": "weeks", "weeksInterval": 1 }] } },
      "id": "schedule-trigger", "name": "Weekly Schedule", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/discord/activity", "method": "GET", "qs": { "period": "7d" }, "options": { "timeout": 15000 } },
      "id": "fetch-activity", "name": "Fetch Discord Activity", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 200]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/community/stats", "method": "GET", "options": { "timeout": 15000 } },
      "id": "fetch-stats", "name": "Fetch Community Stats", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 400]
    },
    {
      "parameters": { "mode": "runOnceForAllItems", "jsCode": "const activity = $('Fetch Discord Activity').first().json;\nconst stats = $('Fetch Community Stats').first().json;\nconst report = {\n  period: '7 days',\n  totalMessages: activity.totalMessages || activity.data?.totalMessages || 0,\n  activeMembers: activity.activeMembers || activity.data?.activeMembers || 0,\n  newMembers: stats.newMembers || stats.data?.newMembers || 0,\n  topChannels: activity.topChannels || [],\n  generatedAt: new Date().toISOString()\n};\nreturn [{ json: report }];" },
      "id": "build-report", "name": "Build Report", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [720, 300]
    },
    {
      "parameters": { "url": "http://host.docker.internal:3010/api/reports", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ type: 'discord-activity', title: 'Weekly Discord Activity', data: $json }) }}", "options": { "timeout": 15000 } },
      "id": "save-report", "name": "Save Report", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 200]
    },
    {
      "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ content: '📈 **Weekly Discord Report**\\nMessages: ' + $json.totalMessages + '\\nActive Members: ' + $json.activeMembers + '\\nNew Members: ' + $json.newMembers }) }}" },
      "id": "discord-notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 400]
    }
  ],
  "connections": {
    "Weekly Schedule": { "main": [[{ "node": "Fetch Discord Activity", "type": "main", "index": 0 }, { "node": "Fetch Community Stats", "type": "main", "index": 0 }]] },
    "Fetch Discord Activity": { "main": [[{ "node": "Build Report", "type": "main", "index": 0 }]] },
    "Fetch Community Stats": { "main": [[{ "node": "Build Report", "type": "main", "index": 0 }]] },
    "Build Report": { "main": [[{ "node": "Save Report", "type": "main", "index": 0 }, { "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
