{
  "name": "02 \u2014 G\u00fcnl\u00fck Mail \u00d6zeti (08:00)",
  "nodes": [
    {
      "parameters": {
        "content": "## \ud83d\udcec G\u00fcnl\u00fck e-posta \u00f6zeti \u2014 her sabah 08:00\n\nSon 24 saatte gelen mailleri Gmail'den \u00e7eker, g\u00f6nderene g\u00f6re\ngruplanm\u0131\u015f T\u00fcrk\u00e7e bir HTML \u00f6zet haz\u0131rlar ve size mail atar.\n\n### Kurulum\n1. Her iki Gmail d\u00fc\u011f\u00fcm\u00fcne de ayn\u0131 **Gmail OAuth2** credential'\u0131n\u0131\n   ba\u011flay\u0131n (Google Cloud kurulum ad\u0131mlar\u0131: README \u00a74-B).\n2. **\u00d6zeti Kendime G\u00f6nder** d\u00fc\u011f\u00fcm\u00fcndeki *To* adresini kendi\n   adresinizle de\u011fi\u015ftirin.\n3. Workflow'u **Active** yap\u0131n.\n\n### Uyarlama\n- Saati de\u011fi\u015ftirmek: **Her Sabah 08:00** d\u00fc\u011f\u00fcm\u00fc.\n- Hangi maillerin dahil olaca\u011f\u0131: **Son 24 Saatin Mailleri**\n  d\u00fc\u011f\u00fcm\u00fcndeki `q` sorgusu. \u00d6rnekler:\n  - Yaln\u0131zca okunmam\u0131\u015flar: ba\u015f\u0131na `is:unread` ekleyin\n  - Yaln\u0131zca birincil sekme: `category:primary` ekleyin\n- `-from:me` par\u00e7as\u0131, \u00f6zetin kendisinin ertesi g\u00fcn \u00f6zete\n  girmesini engeller \u2014 silmeyin.",
        "width": 460,
        "height": 540
      },
      "id": "5c60a767-42ca-4cdc-b364-468ecafc4b49",
      "name": "Not ld4mn",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        80
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "e171307a-3e0f-447a-8541-1cc4c255ac56",
      "name": "Her Sabah 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        40,
        340
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "getAll",
        "returnAll": true,
        "simple": true,
        "filters": {
          "q": "newer_than:1d -in:spam -in:trash -from:me"
        }
      },
      "id": "87508e77-9165-4edd-ac84-7cb62e55fbcc",
      "name": "Son 24 Saatin Mailleri",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        270,
        340
      ],
      "alwaysOutputData": true
    },
    {
      "parameters": {
        "jsCode": "// Gmail'den gelen mesajlar\u0131, g\u00f6nderene g\u00f6re gruplanm\u0131\u015f T\u00fcrk\u00e7e HTML \u00f6zete \u00e7evirir.\nconst esc = (s) => String(s ?? '').replace(/[&<>]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;' }[c]));\n\nconst mesajlar = $input.all()\n  .map((i) => i.json)\n  .filter((m) => m && (m.id || m.threadId));\n\nconst bugun = new Date().toLocaleDateString('tr-TR', {\n  weekday: 'long', day: 'numeric', month: 'long', year: 'numeric',\n});\n\nif (mesajlar.length === 0) {\n  return [{\n    json: {\n      konu: `[n8n] \ud83d\udcec G\u00fcnl\u00fck \u00f6zet \u2014 yeni e-posta yok (${bugun})`,\n      html: '<div style=\"font-family:sans-serif\"><h2>\ud83d\udcec G\u00fcnl\u00fck e-posta \u00f6zeti</h2><p>Son 24 saatte yeni e-posta yok. \ud83c\udf89</p></div>',\n    },\n  }];\n}\n\n// G\u00f6nderene g\u00f6re grupla \u2014 en \u00e7ok mail g\u00f6nderen en \u00fcstte.\nconst gruplar = new Map();\nfor (const m of mesajlar) {\n  const hamKimden = String(m.From || m.from || 'Bilinmeyen g\u00f6nderen');\n  const ad = hamKimden.replace(/<[^>]*>/g, '').replace(/\"/g, '').trim() || hamKimden;\n  if (!gruplar.has(ad)) gruplar.set(ad, []);\n  gruplar.get(ad).push({\n    konu: String(m.Subject || m.subject || '(konu yok)'),\n    ozet: String(m.snippet || '').slice(0, 160),\n  });\n}\n\nconst bolumler = [...gruplar.entries()]\n  .sort((a, b) => b[1].length - a[1].length)\n  .map(([ad, liste]) => {\n    const satirlar = liste\n      .map((k) => `<li style=\"margin:2px 0\"><b>${esc(k.konu)}</b>${k.ozet ? ` \u2014 <span style=\"color:#555\">${esc(k.ozet)}</span>` : ''}</li>`)\n      .join('');\n    return `<h3 style=\"margin:14px 0 4px\">${esc(ad)} <span style=\"color:#888;font-weight:normal\">(${liste.length})</span></h3><ul style=\"margin:4px 0 10px\">${satirlar}</ul>`;\n  })\n  .join('');\n\nconst html = [\n  '<div style=\"font-family:sans-serif;max-width:640px\">',\n  `<h2 style=\"margin-bottom:4px\">\ud83d\udcec G\u00fcnl\u00fck e-posta \u00f6zeti \u2014 ${bugun}</h2>`,\n  `<p>Son 24 saatte <b>${mesajlar.length}</b> e-posta, <b>${gruplar.size}</b> farkl\u0131 g\u00f6nderen.</p>`,\n  bolumler,\n  '<hr style=\"border:none;border-top:1px solid #eee\">',\n  '<p style=\"color:#999;font-size:12px\">Bu \u00f6zet, bilgisayar\u0131n\u0131zdaki n8n taraf\u0131ndan yerel olarak haz\u0131rland\u0131.</p>',\n  '</div>',\n].join('');\n\nreturn [{ json: { konu: `[n8n] \ud83d\udcec G\u00fcnl\u00fck \u00f6zet: ${mesajlar.length} e-posta (${bugun})`, html } }];"
      },
      "id": "76ff0b43-f5ca-4cd4-a359-3bd4f8691444",
      "name": "\u00d6zeti Haz\u0131rla",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        500,
        340
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "sizin-adresiniz@gmail.com",
        "subject": "={{ $json.konu }}",
        "emailType": "html",
        "message": "={{ $json.html }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "149ae5e4-09f3-46f7-8e5b-41bc8523a4c7",
      "name": "\u00d6zeti Kendime G\u00f6nder",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        730,
        340
      ]
    }
  ],
  "connections": {
    "Her Sabah 08:00": {
      "main": [
        [
          {
            "node": "Son 24 Saatin Mailleri",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Son 24 Saatin Mailleri": {
      "main": [
        [
          {
            "node": "\u00d6zeti Haz\u0131rla",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u00d6zeti Haz\u0131rla": {
      "main": [
        [
          {
            "node": "\u00d6zeti Kendime G\u00f6nder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}