{
  "updatedAt": "2026-06-15T19:33:10.391Z",
  "createdAt": "2026-06-15T19:33:10.391Z",
  "id": "BK3LUKLihBNK769I",
  "name": "NOVA Weekly Stats Report",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "id": "wk-trigger",
      "name": "Every Monday 8am NZT",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        250,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 20 * * 0"
            }
          ]
        }
      }
    },
    {
      "id": "wk-http",
      "name": "GET NOVA Health",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "http://localhost:10000/api/health",
        "options": {}
      }
    },
    {
      "id": "wk-format",
      "name": "Format Report",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        650,
        300
      ],
      "parameters": {
        "jsCode": "\nconst h = $input.first().json;\nconst now = new Date();\nconst dateStr = now.toISOString().replace(/[:.]/g, '-').slice(0, 19);\nconst nzDate = now.toLocaleDateString('en-NZ', { timeZone: 'Pacific/Auckland', weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });\nconst sep = '\u2500'.repeat(44);\nconst status = h.ok ? '\u2713 HEALTHY' : '\u2717 DEGRADED';\nconst subject = 'NOVA Weekly Report \u2014 ' + nzDate;\nconst body = [\n  'NOVA Weekly Health Report',\n  'Generated: ' + nzDate,\n  sep,\n  'Overall status:       ' + status,\n  'Ollama (Mistral 7B):  ' + (h.ollamaUp ? 'UP' : 'DOWN'),\n  'Model loaded:         ' + (h.modelLoaded ? 'YES' : 'NO'),\n  'Circuit breaker open: ' + (h.breakerOpen ? 'YES \u2014 degraded' : 'NO \u2014 normal'),\n  sep,\n  'Resources:',\n  '  NZAF        0800 802 437',\n  '  Lifeline    0800 543 354',\n  '  1737        text or call',\n  sep,\n  'M\u0101tauranga NOVA \u00b7 Community Health Initiative \u00b7 Aotearoa NZ',\n  'Hosted on Catalyst Cloud NZ \u2014 data never leaves Aotearoa.',\n].join('\\n');\nreturn [{ json: { subject, body, dateStr } }];\n"
      }
    },
    {
      "id": "wk-save",
      "name": "Save to File",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        850,
        300
      ],
      "parameters": {
        "jsCode": "\nconst fs = require('fs');\nconst { body, dateStr } = $input.first().json;\nconst dir = '/home/ubuntu/reports';\nfs.mkdirSync(dir, { recursive: true });\nfs.writeFileSync(dir + '/weekly_' + dateStr + '.txt', body);\nreturn [{ json: { ...$input.first().json, saved: true } }];\n"
      }
    },
    {
      "id": "wk-email",
      "name": "Send Email Report",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1050,
        300
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "parameters": {
        "fromEmail": "={{ $env.NOVA_GMAIL_USER }}",
        "toEmail": "={{ $env.NOVA_REPORT_TO }}",
        "subject": "={{ $json.subject }}",
        "text": "={{ $json.body }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Every Monday 8am NZT": {
      "main": [
        [
          {
            "node": "GET NOVA Health",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET NOVA Health": {
      "main": [
        [
          {
            "node": "Format Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Report": {
      "main": [
        [
          {
            "node": "Save to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to File": {
      "main": [
        [
          {
            "node": "Send Email Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "staticData": {
    "node:Every Monday 8am NZT": {
      "recurrenceRules": []
    }
  },
  "meta": null,
  "versionId": "ff523194-7742-48f4-9acc-4991fe341c42",
  "activeVersionId": "ff523194-7742-48f4-9acc-4991fe341c42",
  "versionCounter": 4,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-06-15T19:33:10.397Z",
      "createdAt": "2026-06-15T19:33:10.397Z",
      "role": "workflow:owner",
      "workflowId": "BK3LUKLihBNK769I",
      "projectId": "Ulewkx0XO8WcUsFp",
      "project": {
        "updatedAt": "2026-06-15T19:01:42.398Z",
        "createdAt": "2026-06-15T18:58:16.188Z",
        "id": "Ulewkx0XO8WcUsFp",
        "name": "Emanuel Figueroa <emanuel.figueroa.alejandro@gmail.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "290a5642-4625-4650-be11-878711ddb8c1"
      }
    }
  ],
  "tags": [],
  "activeVersion": {
    "updatedAt": "2026-06-15T19:33:10.409Z",
    "createdAt": "2026-06-15T19:33:10.409Z",
    "versionId": "ff523194-7742-48f4-9acc-4991fe341c42",
    "workflowId": "BK3LUKLihBNK769I",
    "nodes": [
      {
        "id": "wk-trigger",
        "name": "Every Monday 8am NZT",
        "type": "n8n-nodes-base.scheduleTrigger",
        "typeVersion": 1.2,
        "position": [
          250,
          300
        ],
        "parameters": {
          "rule": {
            "interval": [
              {
                "field": "cronExpression",
                "expression": "0 20 * * 0"
              }
            ]
          }
        }
      },
      {
        "id": "wk-http",
        "name": "GET NOVA Health",
        "type": "n8n-nodes-base.httpRequest",
        "typeVersion": 4.2,
        "position": [
          450,
          300
        ],
        "parameters": {
          "method": "GET",
          "url": "http://localhost:10000/api/health",
          "options": {}
        }
      },
      {
        "id": "wk-format",
        "name": "Format Report",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          650,
          300
        ],
        "parameters": {
          "jsCode": "\nconst h = $input.first().json;\nconst now = new Date();\nconst dateStr = now.toISOString().replace(/[:.]/g, '-').slice(0, 19);\nconst nzDate = now.toLocaleDateString('en-NZ', { timeZone: 'Pacific/Auckland', weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });\nconst sep = '\u2500'.repeat(44);\nconst status = h.ok ? '\u2713 HEALTHY' : '\u2717 DEGRADED';\nconst subject = 'NOVA Weekly Report \u2014 ' + nzDate;\nconst body = [\n  'NOVA Weekly Health Report',\n  'Generated: ' + nzDate,\n  sep,\n  'Overall status:       ' + status,\n  'Ollama (Mistral 7B):  ' + (h.ollamaUp ? 'UP' : 'DOWN'),\n  'Model loaded:         ' + (h.modelLoaded ? 'YES' : 'NO'),\n  'Circuit breaker open: ' + (h.breakerOpen ? 'YES \u2014 degraded' : 'NO \u2014 normal'),\n  sep,\n  'Resources:',\n  '  NZAF        0800 802 437',\n  '  Lifeline    0800 543 354',\n  '  1737        text or call',\n  sep,\n  'M\u0101tauranga NOVA \u00b7 Community Health Initiative \u00b7 Aotearoa NZ',\n  'Hosted on Catalyst Cloud NZ \u2014 data never leaves Aotearoa.',\n].join('\\n');\nreturn [{ json: { subject, body, dateStr } }];\n"
        }
      },
      {
        "id": "wk-save",
        "name": "Save to File",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          850,
          300
        ],
        "parameters": {
          "jsCode": "\nconst fs = require('fs');\nconst { body, dateStr } = $input.first().json;\nconst dir = '/home/ubuntu/reports';\nfs.mkdirSync(dir, { recursive: true });\nfs.writeFileSync(dir + '/weekly_' + dateStr + '.txt', body);\nreturn [{ json: { ...$input.first().json, saved: true } }];\n"
        }
      },
      {
        "id": "wk-email",
        "name": "Send Email Report",
        "type": "n8n-nodes-base.emailSend",
        "typeVersion": 2.1,
        "position": [
          1050,
          300
        ],
        "credentials": {
          "smtp": {
            "id": "N7qGdXz8oiPovFpM",
            "name": "NOVA Gmail SMTP"
          }
        },
        "parameters": {
          "fromEmail": "={{ $env.NOVA_GMAIL_USER }}",
          "toEmail": "={{ $env.NOVA_REPORT_TO }}",
          "subject": "={{ $json.subject }}",
          "text": "={{ $json.body }}",
          "options": {}
        }
      }
    ],
    "connections": {
      "Every Monday 8am NZT": {
        "main": [
          [
            {
              "node": "GET NOVA Health",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "GET NOVA Health": {
        "main": [
          [
            {
              "node": "Format Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Format Report": {
        "main": [
          [
            {
              "node": "Save to File",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Save to File": {
        "main": [
          [
            {
              "node": "Send Email Report",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "Emanuel Figueroa",
    "name": null,
    "description": null,
    "autosaved": false,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-06-15T19:33:30.675Z",
        "id": 4,
        "workflowId": "BK3LUKLihBNK769I",
        "versionId": "ff523194-7742-48f4-9acc-4991fe341c42",
        "event": "activated",
        "userId": "290a5642-4625-4650-be11-878711ddb8c1"
      }
    ]
  }
}