{
  "name": "linkedin_daily_digest_no_claude",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "custom",
              "cronExpression": "40 7 * * 1-5"
            }
          ]
        }
      },
      "id": "1",
      "name": "Weekday 07:40",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        260,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const raw = $env.LINKEDIN_ITEMS_JSON || '[{\"saved_at\":\"2026-03-11T07:10:00Z\",\"url\":\"https://www.linkedin.com/posts/example\",\"source_name\":\"Exemplo\",\"topic\":\"cybersecurity\",\"title\":\"Post de exemplo\",\"snippet\":\"Substitui este item por links reais do teu LinkedIn inbox.\"}]';\nconst rows = JSON.parse(raw);\nreturn rows.map(r => ({ json: r }));"
      },
      "id": "2",
      "name": "Load Inbox Items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const fresh = items.filter(i => {\n  const ts = i.json.saved_at ? new Date(i.json.saved_at) : null;\n  return ts && !Number.isNaN(ts.getTime()) && (Date.now() - ts.getTime() < 24 * 60 * 60 * 1000);\n});\n\nreturn fresh.length\n  ? fresh\n  : [{\n      json: {\n        saved_at: new Date().toISOString(),\n        url: '',\n        source_name: 'Sistema',\n        topic: 'market',\n        title: 'Sem novidades',\n        snippet: 'N\u00e3o existem itens recentes no inbox.'\n      }\n    }];"
      },
      "id": "3",
      "name": "Filter Last 24h",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        740,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const rows = items.map(i => i.json).slice(0, 10);\n\nconst htmlItems = rows.map(i => `\n  <li>\n    <a href=\"${i.url || '#'}\">${i.title || 'Sem t\u00edtulo'}</a><br>\n    <small>Fonte: ${i.source_name || 'N/A'} | Tema: ${i.topic || 'N/A'}</small><br>\n    <small>${i.snippet || ''}</small>\n  </li>\n`).join('');\n\nconst html = `\n<html>\n  <body style=\"font-family:-apple-system,BlinkMacSystemFont,Arial;line-height:1.5;max-width:860px;margin:auto;\">\n    <h2>LinkedIn Daily Digest</h2>\n    <p>${new Date().toLocaleString('pt-PT')}</p>\n    <ul>${htmlItems || '<li>Sem novidades relevantes.</li>'}</ul>\n  </body>\n</html>`;\n\nconst text = [\n  'LinkedIn Daily Digest',\n  new Date().toLocaleString('pt-PT'),\n  '',\n  ...rows.map(i => `- ${i.title || 'Sem t\u00edtulo'} | ${i.source_name || 'N/A'} | ${i.url || ''}`)\n].join('\\n');\n\nreturn [{ json: { html, text } }];"
      },
      "id": "4",
      "name": "Build Digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        980,
        300
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "to": "={{$env.DIGEST_EMAIL}}",
        "subject": "={{'LinkedIn Daily Digest \u2014 ' + $now.setZone('Europe/Lisbon').toFormat('dd-LL-yyyy')}}",
        "emailType": "html",
        "message": "={{$json.html}}"
      },
      "id": "5",
      "name": "Send Gmail",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1220,
        300
      ]
    }
  ],
  "connections": {
    "Weekday 07:40": {
      "main": [
        [
          {
            "node": "Load Inbox Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Inbox Items": {
      "main": [
        [
          {
            "node": "Filter Last 24h",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Last 24h": {
      "main": [
        [
          {
            "node": "Build Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Digest": {
      "main": [
        [
          {
            "node": "Send Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "linkedin-digest-no-claude-v1",
  "tags": []
}