{
  "name": "Weekly smenso Project Status Report via Email",
  "tags": [],
  "nodes": [
    {
      "id": "c1d2e3f4-0001-0001-0001-000000000001",
      "name": "Every Monday at 8am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "notes": "Runs every Monday at 8:00 AM.\nAdjust the cron expression to your preferred day and time.",
      "position": [
        160,
        208
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c1d2e3f4-0002-0002-0002-000000000002",
      "name": "Get All Projects",
      "type": "n8n-nodes-smenso.smenso",
      "position": [
        384,
        208
      ],
      "parameters": {
        "resource": "project",
        "operation": "getMany"
      },
      "credentials": {
        "smensoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c1d2e3f4-0003-0003-0003-000000000003",
      "name": "Build HTML Report",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        208
      ],
      "parameters": {
        "jsCode": "const projects = items.map(item => item.json);\nconst date = new Date().toLocaleDateString('en-GB', {\n  weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'\n});\n\nconst rows = projects.map(p => {\n  const title = p.title ?? p.name ?? 'Unnamed Project';\n  const start = p.startDate ? new Date(p.startDate).toLocaleDateString('en-GB') : '\u2014';\n  const end = p.endDate ? new Date(p.endDate).toLocaleDateString('en-GB') : '\u2014';\n  return `<tr><td style=\"padding:8px;border:1px solid #ddd;\">${title}</td><td style=\"padding:8px;border:1px solid #ddd;text-align:center;\">${start}</td><td style=\"padding:8px;border:1px solid #ddd;text-align:center;\">${end}</td></tr>`;\n}).join('');\n\nconst html = `\n<html><body style=\"font-family:Arial,sans-serif;color:#333;\">\n<h2 style=\"color:#1a1a2e;\">\ud83d\udcca Weekly smenso Project Report</h2>\n<p style=\"color:#666;\">${date}</p>\n<p>You have <strong>${projects.length} active project(s)</strong> in your smenso workspace.</p>\n<table style=\"border-collapse:collapse;width:100%;margin-top:16px;\">\n  <thead>\n    <tr style=\"background:#f0f0f0;\">\n      <th style=\"padding:8px;border:1px solid #ddd;text-align:left;\">Project</th>\n      <th style=\"padding:8px;border:1px solid #ddd;\">Start Date</th>\n      <th style=\"padding:8px;border:1px solid #ddd;\">End Date</th>\n    </tr>\n  </thead>\n  <tbody>${rows}</tbody>\n</table>\n<p style=\"margin-top:24px;color:#999;font-size:12px;\">This report was automatically generated by n8n + smenso.</p>\n</body></html>\n`;\n\nreturn [{ json: { html, projectCount: projects.length, date } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "c1d2e3f4-0004-0004-0004-000000000004",
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "notes": "Replace YOUR_EMAIL@company.com with the recipient email address.\nYou can also replace this node with Microsoft Outlook or SMTP.",
      "position": [
        832,
        208
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "={{ $json.html }}",
        "options": {},
        "subject": "=\ud83d\udcca Weekly smenso Project Report \u2013 {{ $json.date }}",
        "emailType": "html"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "c1d2e3f4-0005-0005-0005-000000000005",
      "name": "README",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        420
      ],
      "parameters": {
        "color": 6,
        "width": 620,
        "height": 340,
        "content": "## \ud83d\udcca Weekly smenso Project Status Report via Email\n\n**What this workflow does:**\nEvery Monday at 8:00 AM, it fetches all active projects from your smenso workspace and sends a formatted HTML status report via email \u2014 perfect for management reporting and weekly standups.\n\n**Setup:**\n1. Set your **smenso API** credentials\n2. Set your **Gmail** credentials (or replace with Outlook / SMTP node)\n3. Replace `YOUR_EMAIL@company.com` in the **Send Email** node with the recipient address\n\n**Customize:**\n- Change the schedule in **Every Monday at 8am** (cron: `0 8 * * 1`)\n- Add more project fields in **Build HTML Report** (e.g. status, budget)\n- Replace Gmail with **Microsoft Outlook** or **Send Email (SMTP)** node\n\n**Tip:** Run smenso \u2192 Project \u2192 Get Many manually first to see which fields are available in your workspace."
      },
      "typeVersion": 1
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1",
  "staticData": null,
  "connections": {
    "Get All Projects": {
      "main": [
        [
          {
            "node": "Build HTML Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build HTML Report": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Monday at 8am": {
      "main": [
        [
          {
            "node": "Get All Projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "triggerCount": 0
}