Weekly Email Summary

    Shared 12/30/2025

    13 views

    Visual Workflow

    JSON Code

    {
      "id": "PKonx3BAAOMRGJOV",
      "meta": {
        "instanceId": "f23f54443e936fb3cc804bf83f365997eb2bcbfaff8b4dc794bba74c6939d517",
        "templateCredsSetupCompleted": true
      },
      "name": "Weekly Email Summary",
      "tags": [],
      "nodes": [
        {
          "id": "25d03a4d-4e98-4f85-97e5-252c2305a930",
          "name": "Schedule Trigger",
          "type": "n8n-nodes-base.scheduleTrigger",
          "position": [
            0,
            -64
          ],
          "parameters": {
            "rule": {
              "interval": [
                {
                  "field": "weeks",
                  "triggerAtDay": [
                    5
                  ],
                  "triggerAtHour": 18
                }
              ]
            }
          },
          "typeVersion": 1.3
        },
        {
          "id": "967b1e39-5490-424a-b459-a96577e48964",
          "name": "Get many messages",
          "type": "n8n-nodes-base.gmail",
          "position": [
            224,
            -64
          ],
          "webhookId": "4068c879-770f-4184-b840-19fb64f3f911",
          "parameters": {
            "filters": {
              "receivedAfter": "={{ new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toDateTime() }}"
            },
            "operation": "getAll",
            "returnAll": true
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "0lLMz09MEIOzRbW3",
              "name": "Gmail account"
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "a268dfe0-bf71-44c4-bf1f-c89dc7745d81",
          "name": "AI Agent",
          "type": "@n8n/n8n-nodes-langchain.agent",
          "maxTries": 5,
          "position": [
            1472,
            -48
          ],
          "parameters": {
            "text": "=You are an assistant that classifies and summarizes emails for a weekly productivity and spending report.\n\nFor each email, return a single JSON object with the following fields:\n\n* **category**: one of:\n    * `\"accomplished\"` → something completed or confirmed\n    * `\"open\"` → requires action from me\n    * `\"waiting\"` → waiting for a reply, delivery, or confirmation\n    * `\"purchase\"` → payment, receipt, invoice, subscription\n    * `\"ignore\"` → newsletters, ads, irrelevant info\n * **short_summary**: one concise sentence describing the email in plain language\n  * **action_required**: `true` if I need to do something, otherwise `false`\n  * **amount**: numeric value (no currency symbol) if a monetary amount is involved, otherwise `null`\n  * **vendor**: company or sender name if relevant (especially for purchases), otherwise `null`\n \n**Guidelines:**\n* Be consistent so results can be aggregated over a week.\n* Prefer `\"purchase\"` over other categories when money is involved.\n * Use `\"accomplished\"` only if no further action is needed.\n * Extract amounts and vendors whenever possible.\n * Do not include explanations or extra text—**output JSON only**. If there are multiple emails for the same payment, for example, a PayPal email nd the official email, just return the official email. Otherwise, include all emails!\n\nRespond with a single JSON list. Strictly use this schema in your response. Dont add any other text.\n[\n  {\n    \"category\": \"accomplished | open | other | purchase | ignore\",\n    \"short_summary\": \"string\",\n    \"action_required\": \"boolean\",\n    \"amount\": \"number | null\",\n    \"vendor\": \"string | null\"\n  }\n]\n\n\n **Input emails (array):**\n\n```json\n{{ JSON.stringify(($json.emails || []).map((e,i) => ({ emailNumber: i+1, ...e })), null, 2)\n }}\n```\n\n\n",
            "options": {},
            "promptType": "define",
            "hasOutputParser": true
          },
          "retryOnFail": true,
          "typeVersion": 3.1,
          "waitBetweenTries": 5000
        },
        {
          "id": "87f24638-b2d6-4cf9-b2ea-1513937955b5",
          "name": "Wait",
          "type": "n8n-nodes-base.wait",
          "position": [
            960,
            -48
          ],
          "webhookId": "45ad7a89-708a-41e6-9995-f99382cdb311",
          "parameters": {
            "amount": 1
          },
          "typeVersion": 1.1
        },
        {
          "id": "ced2d2fe-e3c9-4ca7-8411-269035e4f5cb",
          "name": "Loop Over Items1",
          "type": "n8n-nodes-base.splitInBatches",
          "position": [
            448,
            -64
          ],
          "parameters": {
            "options": {},
            "batchSize": 15
          },
          "typeVersion": 3
        },
        {
          "id": "db488545-badc-482f-b992-b692b271d58d",
          "name": "Aggregate",
          "type": "n8n-nodes-base.aggregate",
          "position": [
            1264,
            -48
          ],
          "parameters": {
            "include": "specifiedFields",
            "options": {},
            "aggregate": "aggregateAllItemData",
            "fieldsToInclude": "From,Subject, Snippet",
            "destinationFieldName": "emails"
          },
          "typeVersion": 1
        },
        {
          "id": "ce025e74-3faf-4ede-81c7-79a6cdaa87a1",
          "name": "Rename Keys1",
          "type": "n8n-nodes-base.renameKeys",
          "position": [
            672,
            -48
          ],
          "parameters": {
            "keys": {
              "key": [
                {
                  "newKey": "Snippet",
                  "currentKey": "snippet"
                }
              ]
            },
            "additionalOptions": {}
          },
          "typeVersion": 1
        },
        {
          "id": "2f4fbd4c-2b6f-47cc-a99c-b7e139c46509",
          "name": "Mistral Cloud Chat Model",
          "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
          "position": [
            1472,
            144
          ],
          "parameters": {
            "model": "mistral-medium",
            "options": {}
          },
          "credentials": {
            "mistralCloudApi": {
              "id": "881IEV8fe5F6l3tO",
              "name": "Mistral Cloud account"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "4f0cf288-764f-4ce3-a42b-1ba1f33cdde6",
          "name": "Split Out1",
          "type": "n8n-nodes-base.splitOut",
          "position": [
            1824,
            -48
          ],
          "parameters": {
            "options": {},
            "fieldToSplitOut": "output"
          },
          "typeVersion": 1
        },
        {
          "id": "fcc374e3-866d-41f5-943e-9ad32a5960de",
          "name": "Structured Output Parser1",
          "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
          "position": [
            1616,
            144
          ],
          "parameters": {
            "schemaType": "manual",
            "inputSchema": "[\n  {\n    \"category\": \"accomplished | open | other | purchase | ignore\",\n    \"short_summary\": \"string\",\n    \"action_required\": \"boolean\",\n    \"amount\": \"number | null\",\n    \"vendor\": \"string | null\"\n  }\n]"
          },
          "typeVersion": 1.3
        },
        {
          "id": "0ddf17bc-8b75-4183-8b35-a4a74a843d99",
          "name": "AI Agent1",
          "type": "@n8n/n8n-nodes-langchain.agent",
          "maxTries": 5,
          "position": [
            896,
            -448
          ],
          "parameters": {
            "text": "=Create a weekly email summary in **HTML** using the following JSON data:\n\n{{ JSON.stringify($json[\"\"], null, 2) }}\n\n\nRequirements:\n\n* Include four sections with these headers and emojis:\n1. 💸 Purchases Overview. Including a total spending estimate.\n2. 📝 Open\n3. ✅ Accomplished\n4. ⏳ Other\n\n\n* Each section should list items as bullet points.\n* If a section is empty, include a witty or sarcastic placeholder.\n* End with a short, sarcastic summary of the week.\n* Make the HTML clean, readable, and email-friendly.\n* Ensure the layout and styling are consistent each week (template style).\n* Be concise, slightly humorous, and engaging.\n\n---\n\n**HTML Template (use this in a Code node or email node):**\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n   <style>\n    body {\n      font-family: Arial, sans-serif;\n      line-height: 1.5;\n      color: #333;\n      background: #f9f9f9;\n      padding: 20px;\n    }\n    h1 {\n      color: #264653;\n      margin-bottom: 10px;\n    }\n    h2 {\n      color: #2a9d8f;\n      border-bottom: 1px solid #e0e0e0;\n      padding-bottom: 3px;\n      margin-bottom: 5px;\n      font-size: 18px;\n    }\n    ul {\n      padding-left: 20px;\n      margin-top: 0;\n      margin-bottom: 5px;\n    }\n    .section {\n      margin-bottom: 8px; /* smaller spacing between sections */\n      background: #fff;\n      padding: 8px 12px;\n      border-radius: 6px;\n      box-shadow: 0 1px 3px rgba(0,0,0,0.05);\n    }\n    .sarcasm {\n      color: #e76f51;\n      font-style: italic;\n      margin-top: 10px;\n    }\n  </style>\n</head>\n<body>\n  <h1>📬 Weekly Summary</h1>\n\n  <div class=\"section\">\n    <h2>✅ Accomplished</h2>\n    <ul>\n       ...\n    </ul>\n  </div>\n\n  <p class=\"sarcasm\">\n    ...\n  </p>\n</body>\n</html>\n```",
            "options": {},
            "promptType": "define",
            "hasOutputParser": true
          },
          "retryOnFail": true,
          "typeVersion": 3.1,
          "waitBetweenTries": 5000
        },
        {
          "id": "1c89a17a-4709-4d61-a4b0-653d8ab11914",
          "name": "Mistral Cloud Chat Model1",
          "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
          "position": [
            896,
            -224
          ],
          "parameters": {
            "model": "mistral-medium",
            "options": {}
          },
          "credentials": {
            "mistralCloudApi": {
              "id": "881IEV8fe5F6l3tO",
              "name": "Mistral Cloud account"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "5500d3c6-32a2-46cf-b5f7-558dd084dcee",
          "name": "Aggregate1",
          "type": "n8n-nodes-base.aggregate",
          "position": [
            688,
            -448
          ],
          "parameters": {
            "options": {},
            "aggregate": "aggregateAllItemData",
            "destinationFieldName": ""
          },
          "typeVersion": 1
        },
        {
          "id": "2441d436-1953-4915-8618-f4270d4c0e19",
          "name": "Send a message",
          "type": "n8n-nodes-base.gmail",
          "position": [
            1280,
            -448
          ],
          "webhookId": "b534c96d-6f06-48af-9ff3-ee4652366c6d",
          "parameters": {
            "sendTo": "manuel.lerchner1111@gmail.com",
            "message": "={{ $json.output.html }}",
            "options": {},
            "subject": "n8n - Weekly Summary"
          },
          "credentials": {
            "gmailOAuth2": {
              "id": "0lLMz09MEIOzRbW3",
              "name": "Gmail account"
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "51213dab-6abf-4f1f-b597-a75c7c517f9d",
          "name": "Structured Output Parser",
          "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
          "position": [
            1040,
            -224
          ],
          "parameters": {
            "schemaType": "manual",
            "inputSchema": "{\n\t\"output\": \"string\"\n}"
          },
          "typeVersion": 1.3
        }
      ],
      "active": false,
      "pinData": {},
      "settings": {
        "availableInMCP": false,
        "executionOrder": "v1"
      },
      "versionId": "35625817-da1b-4b86-b119-8150cc5a424b",
      "connections": {
        "Wait": {
          "main": [
            [
              {
                "node": "Aggregate",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "AI Agent": {
          "main": [
            [
              {
                "node": "Split Out1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "AI Agent1": {
          "main": [
            [
              {
                "node": "Send a message",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Aggregate": {
          "main": [
            [
              {
                "node": "AI Agent",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Aggregate1": {
          "main": [
            [
              {
                "node": "AI Agent1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Split Out1": {
          "main": [
            [
              {
                "node": "Loop Over Items1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Rename Keys1": {
          "main": [
            [
              {
                "node": "Wait",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Loop Over Items1": {
          "main": [
            [
              {
                "node": "Aggregate1",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Rename Keys1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Schedule Trigger": {
          "main": [
            [
              {
                "node": "Get many messages",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Get many messages": {
          "main": [
            [
              {
                "node": "Loop Over Items1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Mistral Cloud Chat Model": {
          "ai_languageModel": [
            [
              {
                "node": "AI Agent",
                "type": "ai_languageModel",
                "index": 0
              }
            ]
          ]
        },
        "Structured Output Parser": {
          "ai_outputParser": [
            [
              {
                "node": "AI Agent1",
                "type": "ai_outputParser",
                "index": 0
              }
            ]
          ]
        },
        "Mistral Cloud Chat Model1": {
          "ai_languageModel": [
            [
              {
                "node": "AI Agent1",
                "type": "ai_languageModel",
                "index": 0
              }
            ]
          ]
        },
        "Structured Output Parser1": {
          "ai_outputParser": [
            [
              {
                "node": "AI Agent",
                "type": "ai_outputParser",
                "index": 0
              }
            ]
          ]
        }
      }
    }