{
  "name": "Vorlux AI | Feedback Aggregator",
  "active": false,
  "nodes": [
    { "parameters": { "rule": { "interval": [{ "field": "days", "daysInterval": 1 }] } }, "id": "sched", "name": "Daily Schedule", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/suggestions", "method": "GET", "qs": { "status": "new", "limit": 50 }, "options": { "timeout": 15000 } }, "id": "suggestions", "name": "Fetch Suggestions", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 150] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/support/tickets", "method": "GET", "qs": { "status": "open", "limit": 50 }, "options": { "timeout": 15000 } }, "id": "tickets", "name": "Fetch Support Tickets", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/suggestions/trending", "method": "GET", "options": { "timeout": 15000 } }, "id": "trending", "name": "Fetch Trending Feedback", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 450] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const suggestions = $('Fetch Suggestions').first().json.data || [];\nconst tickets = $('Fetch Support Tickets').first().json.data || [];\nconst trending = $('Fetch Trending Feedback').first().json.data || [];\nconst categories = {};\n[...suggestions, ...tickets].forEach(item => {\n  const cat = item.category || item.type || 'general';\n  if (!categories[cat]) categories[cat] = { count: 0, items: [] };\n  categories[cat].count++;\n  if (categories[cat].items.length < 3) categories[cat].items.push(item.title || item.subject);\n});\nreturn [{ json: {\n  totalSuggestions: suggestions.length,\n  openTickets: tickets.length,\n  trendingCount: trending.length,\n  categories,\n  topTrending: trending.slice(0, 5).map(t => t.title || t.topic),\n  generatedAt: new Date().toISOString()\n} }];" }, "id": "aggregate", "name": "Aggregate Feedback", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [740, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/reports", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ type: 'feedback', title: 'Daily Feedback Summary', data: $json }) }}", "options": { "timeout": 15000 } }, "id": "save", "name": "Save Report", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [980, 200] },
    { "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ content: '📝 **Daily Feedback Summary**\\nSuggestions: ' + $json.totalSuggestions + '\\nOpen Tickets: ' + $json.openTickets + '\\nTrending: ' + $json.topTrending.slice(0, 3).join(', ') }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [980, 400] }
  ],
  "connections": {
    "Daily Schedule": { "main": [[{ "node": "Fetch Suggestions", "type": "main", "index": 0 }, { "node": "Fetch Support Tickets", "type": "main", "index": 0 }, { "node": "Fetch Trending Feedback", "type": "main", "index": 0 }]] },
    "Fetch Suggestions": { "main": [[{ "node": "Aggregate Feedback", "type": "main", "index": 0 }]] },
    "Fetch Support Tickets": { "main": [[{ "node": "Aggregate Feedback", "type": "main", "index": 0 }]] },
    "Fetch Trending Feedback": { "main": [[{ "node": "Aggregate Feedback", "type": "main", "index": 0 }]] },
    "Aggregate Feedback": { "main": [[{ "node": "Save Report", "type": "main", "index": 0 }, { "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
