{
  "name": "Vorlux AI | Monthly Analytics Report",
  "active": false,
  "nodes": [
    { "parameters": { "rule": { "interval": [{ "field": "months", "monthsInterval": 1 }] } }, "id": "sched", "name": "Monthly Schedule", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/analytics/dashboard", "method": "GET", "qs": { "period": "30d" }, "options": { "timeout": 30000 } }, "id": "analytics", "name": "Monthly Analytics", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 200] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/finance/stats", "method": "GET", "qs": { "period": "30d" }, "options": { "timeout": 15000 } }, "id": "finance", "name": "Monthly Finance", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 400] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const analytics = $('Monthly Analytics').first().json;\nconst finance = $('Monthly Finance').first().json;\nreturn [{ json: {\n  month: new Date().toLocaleDateString('en-US', { month: 'long', year: 'numeric' }),\n  visitors: analytics.visitors || 0,\n  pageViews: analytics.pageViews || 0,\n  bounceRate: analytics.bounceRate || '0%',\n  avgSessionDuration: analytics.avgSession || '0m',\n  revenue: finance.totalRevenue || 0,\n  mrr: finance.mrr || 0,\n  growth: finance.growth || '0%',\n  topPages: analytics.topPages || [],\n  generatedAt: new Date().toISOString()\n} }];" }, "id": "compile", "name": "Compile Monthly 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: 'monthly-analytics', title: 'Monthly Analytics - ' + $json.month, data: $json }) }}", "options": { "timeout": 15000 } }, "id": "save", "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: '📊 **Monthly Analytics — ' + $json.month + '**\\n👁️ Visitors: ' + $json.visitors + '\\n📄 Page Views: ' + $json.pageViews + '\\n💰 Revenue: $' + $json.revenue + '\\n📈 Growth: ' + $json.growth }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 400] }
  ],
  "connections": {
    "Monthly Schedule": { "main": [[{ "node": "Monthly Analytics", "type": "main", "index": 0 }, { "node": "Monthly Finance", "type": "main", "index": 0 }]] },
    "Monthly Analytics": { "main": [[{ "node": "Compile Monthly Report", "type": "main", "index": 0 }]] },
    "Monthly Finance": { "main": [[{ "node": "Compile Monthly Report", "type": "main", "index": 0 }]] },
    "Compile Monthly Report": { "main": [[{ "node": "Save Report", "type": "main", "index": 0 }, { "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
