{
  "name": "Gmail Daily Inbox Digest",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [{ "field": "hours", "hoursInterval": 24 }]
        }
      },
      "id": "gdd00001-0001-4000-8000-000000000001",
      "name": "Schedule Daily at 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "operation": "getAll",
        "filters": {
          "readStatus": "unread",
          "receivedAfter": "={{ $now.minus({hours:24}).toISO() }}"
        },
        "limit": 50,
        "options": {}
      },
      "id": "gdd00001-0002-4000-8000-000000000002",
      "name": "Fetch Unread Emails",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an email assistant. Summarize the list of emails provided into a concise daily digest with bullet points. Group by topic if possible. Include sender and subject for each item."
            },
            {
              "role": "user",
              "content": "={{ $items().map(i => `From: ${i.json.from}\\nSubject: ${i.json.subject}\\nSnippet: ${i.json.snippet}`).join('\\n---\\n') }}"
            }
          ]
        },
        "options": {
          "temperature": 0.3,
          "maxTokens": 800
        }
      },
      "id": "gdd00001-0003-4000-8000-000000000003",
      "name": "Summarize with GPT",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [680, 300]
    },
    {
      "parameters": {
        "operation": "send",
        "toList": "={{ $env.DIGEST_RECIPIENT }}",
        "subject": "Your Daily Inbox Digest — {{ $now.toFormat('LLL dd yyyy') }}",
        "message": "={{ $json.message.content }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "gdd00001-0004-4000-8000-000000000004",
      "name": "Send Digest Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Schedule Daily at 7am": {
      "main": [[{ "node": "Fetch Unread Emails", "type": "main", "index": 0 }]]
    },
    "Fetch Unread Emails": {
      "main": [[{ "node": "Summarize with GPT", "type": "main", "index": 0 }]]
    },
    "Summarize with GPT": {
      "main": [[{ "node": "Send Digest Email", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
