{
  "name": "Vorlux AI | Daily Email Digest",
  "nodes": [
    {
      "id": "888d38c6-8ae4-4eb9-be37-2e9457781b92",
      "name": "Daily 8AM",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        220,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 24
            }
          ]
        }
      }
    },
    {
      "id": "26350128-e23f-44f8-8761-e186b6183fe0",
      "name": "Gather Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const hubUrl = $env.VORLUX_HUB_URL || 'http://localhost:3010';\nconst [tasks, posts, cron, health] = await Promise.all([\n  fetch(hubUrl + '/api/tasks?completed_since=24h&limit=10').then(r => r.json()).catch(() => ({data:[]})),\n  fetch(hubUrl + '/api/blog/posts?period=1d&status=published&limit=5').then(r => r.json()).catch(() => ({data:[]})),\n  fetch(hubUrl + '/api/cron/tick').then(r => r.json()).catch(() => ({})),\n  fetch(hubUrl + '/api/health').then(r => r.json()).catch(() => ({}))\n]);\nreturn [{json: {\n  tasksCompleted: (tasks.data || []).length,\n  postsPublished: (posts.data || []).length,\n  postTitles: (posts.data || []).map(p => p.title),\n  cronHealth: cron.executedCount || 0,\n  systemHealth: health.status || 'unknown',\n  date: new Date().toISOString().split('T')[0]\n}}];"
      },
      "notes": "Aggregates daily platform activity"
    },
    {
      "id": "e4822b52-43e0-43ba-9100-8276efb411bd",
      "name": "Format Digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        700,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d = $input.first().json;\nconst html = '<h2>Vorlux AI HUB Daily Digest \u2014 ' + d.date + '</h2>' +\n  '<h3>\ud83d\udcca Overview</h3><ul>' +\n  '<li>Tasks completed: <b>' + d.tasksCompleted + '</b></li>' +\n  '<li>Blog posts published: <b>' + d.postsPublished + '</b></li>' +\n  '<li>Cron executions: <b>' + d.cronHealth + '</b></li>' +\n  '<li>System health: <b>' + d.systemHealth + '</b></li></ul>' +\n  (d.postTitles.length ? '<h3>\ud83d\udcdd New Posts</h3><ul>' + d.postTitles.map(t => '<li>' + t + '</li>').join('') + '</ul>' : '') +\n  '<p><small>This digest is generated automatically by Vorlux AI HUB</small></p>';\nreturn [{json: {subject: 'Vorlux AI Daily Digest \u2014 ' + d.date, html, text: html.replace(/<[^>]*>/g, '')}}];"
      }
    },
    {
      "id": "16d42f2a-8b18-4051-a9a5-5d57f57ecce6",
      "name": "Send Email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/email/send",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({to: \"founder\", subject: $json.subject, html: $json.html}) }}",
        "options": {
          "timeout": 15000
        }
      }
    },
    {
      "id": "e2d87559-e77d-4170-9f16-a8e30a93058b",
      "name": "Discord Summary",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        940,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_OPS_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"\ud83d\udce7 {{ $json.subject }}\",\"description\":\"Tasks: {{ $node[\"Gather Data\"].json.tasksCompleted }} | Posts: {{ $node[\"Gather Data\"].json.postsPublished }} | Cron: {{ $node[\"Gather Data\"].json.cronHealth }}\",\"color\":5793266}]}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Daily 8AM": {
      "main": [
        [
          {
            "node": "Gather Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gather Data": {
      "main": [
        [
          {
            "node": "Format Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Digest": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Discord Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}