{
  "id": "lPYVaz2xbN5zFDIL",
  "name": "My workflow",
  "tags": [
    {
      "id": "DaQLpYItTEM2y8Gt",
      "name": "Product",
      "createdAt": "2025-06-17T10:48:17.486Z",
      "updatedAt": "2025-06-17T10:48:17.486Z"
    },
    {
      "id": "6X5c5WbCRWtxJbl2",
      "name": "AI",
      "createdAt": "2025-06-17T10:48:17.367Z",
      "updatedAt": "2025-06-17T10:48:17.367Z"
    },
    {
      "id": "ycHNTMiM8vy98zu1",
      "name": "Building blocks",
      "createdAt": "2025-06-17T10:48:17.563Z",
      "updatedAt": "2025-06-17T10:48:17.563Z"
    },
    {
      "id": "UJ6au0mv063gOupq",
      "name": "Finance",
      "createdAt": "2025-06-17T10:48:17.583Z",
      "updatedAt": "2025-06-17T10:48:17.583Z"
    },
    {
      "id": "CaWiGPzJpyfUHdxp",
      "name": "IT Ops",
      "createdAt": "2025-06-17T10:48:17.388Z",
      "updatedAt": "2025-06-17T10:48:17.388Z"
    },
    {
      "id": "6Uolue5XigSZ2IYx",
      "name": "OpenAI",
      "createdAt": "2025-06-17T10:48:17.508Z",
      "updatedAt": "2025-06-17T10:48:17.508Z"
    },
    {
      "id": "nA8GpDM4XoG5aJ0A",
      "name": "Marketing",
      "createdAt": "2025-06-17T10:48:17.532Z",
      "updatedAt": "2025-06-17T10:48:17.532Z"
    },
    {
      "id": "J4gTJX9lSPm3wByF",
      "name": "Support",
      "createdAt": "2025-06-17T10:48:17.464Z",
      "updatedAt": "2025-06-17T10:48:17.464Z"
    },
    {
      "id": "i294x7TPtUQgJkmv",
      "name": "HR",
      "createdAt": "2025-06-17T10:48:17.426Z",
      "updatedAt": "2025-06-17T10:48:17.426Z"
    }
  ],
  "nodes": [
    {
      "id": "895894ff-943d-4cd0-9311-791b35e4ca57",
      "name": "Fetch Emails - Past 24 Hours",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -800,
        180
      ],
      "parameters": {
        "filters": {
          "q": "={{ \n (() => {\n const yesterday = new Date();\n yesterday.setDate(yesterday.getDate() - 1);\n return `isb.quantana@quantana.in after:${yesterday.getFullYear()}/${(yesterday.getMonth() + 1).toString().padStart(2, '0')}/${yesterday.getDate().toString().padStart(2, '0')}`;\n })()\n}}"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "5518a4f6-5d68-46bf-b29b-1830379917a9",
      "name": "Organize Email Data - Morning",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -580,
        180
      ],
      "parameters": {
        "include": "specifiedFields",
        "options": {},
        "aggregate": "aggregateAllItemData",
        "fieldsToInclude": "id, From, To, CC, snippet"
      },
      "typeVersion": 1
    },
    {
      "id": "d5598f1c-86a2-49b3-b659-bba4d063878c",
      "name": "Send Summary - Morning",
      "type": "n8n-nodes-base.gmail",
      "position": [
        16,
        180
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Email Summary - isbonline@quantana.in</title>\n <style>\n body {\n font-family: Arial, sans-serif;\n margin: 0;\n padding: 0;\n background-color: #f9f9f9;\n color: #333;\n line-height: 1.6;\n }\n .email-container {\n max-width: 600px;\n margin: 20px auto;\n background: #ffffff;\n border: 1px solid #ddd;\n border-radius: 10px;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);\n }\n .email-header {\n background-color: #0073e6;\n color: #fff;\n padding: 20px;\n text-align: center;\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n }\n .email-header h1 {\n margin: 0;\n font-size: 24px;\n }\n .email-content {\n padding: 20px;\n }\n .section-title {\n font-size: 20px;\n color: #0073e6;\n margin-bottom: 10px;\n }\n ul {\n list-style: none;\n padding: 0;\n }\n ul li {\n margin: 10px 0;\n padding: 10px;\n background: #f4f4f4;\n border-left: 4px solid #0073e6;\n border-radius: 5px;\n }\n .action-item {\n font-weight: bold;\n margin: 5px 0;\n }\n .action-detail {\n margin-left: 10px;\n }\n .email-footer {\n background-color: #0073e6;\n color: #fff;\n text-align: center;\n padding: 10px;\n font-size: 14px;\n border-bottom-left-radius: 10px;\n border-bottom-right-radius: 10px;\n }\n </style>\n</head>\n<body>\n <div class=\"email-container\">\n <div class=\"email-header\">\n <h1>Email Summary</h1>\n </div>\n <div class=\"email-content\">\n <div>\n <h2 class=\"section-title\">Summary of Emails:</h2>\n <ul>\n {{ $json.message.content.summary_of_emails.map(email => `<li>${email}</li>`).join('') }}\n </ul>\n </div>\n <div>\n <h2 class=\"section-title\">Actions:</h2>\n <ul>\n {{ $json.message.content.actions.map(action => `\n <li>\n <span class=\"action-item\">${action.name}:</span>\n <span class=\"action-detail\">${action.action}</span>\n </li>\n `).join('') }}\n </ul>\n </div>\n </div>\n <div class=\"email-footer\">\n <p>Generated by Quantana ESAgent <br /> A Quantana AI Labs Initiative\n </div>\n </div>\n</body>\n</html>",
        "options": {
          "ccList": "user@example.com",
          "appendAttribution": false,
          "replyToSenderOnly": false
        },
        "subject": "=ESAgent - {{ new Date(new Date().setDate(new Date().getDate() - 1)).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) }}-00:00 to {{ new Date(new Date().setDate(new Date().getDate())).toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }) }}-07:00AM"
      },
      "typeVersion": 2.1
    },
    {
      "id": "7480f9af-2026-437c-800c-be49eef1895b",
      "name": "Daily 8AM Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1020,
        180
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ab7c5ea2-81a6-4d8d-932c-2de023164304",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -332,
        400
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ddf9f7ee-630e-4b3d-8e84-d157d129c671",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -212,
        400
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "309bfb47-72e1-4396-ad5f-dc656ea4eefa",
      "name": "Email Summarizer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -360,
        180
      ],
      "parameters": {
        "options": {
          "systemMessage": "Email Processing System\n\nStep 1: Extract Key Details\nRead the email thoroughly and identify:\n\nMain topics discussed\n\nCritical data points (dates, numbers, names)\n\nExplicit requests or requirements\n\nProblems or concerns raised\n\nStep 2: Organize Output\nSummary of Email\nBullet-point list of key takeaways\n\nExample:\n\nProject deadline extended to March 15\n\nNew compliance rules apply to all vendors\n\nIssues Identified\nList problems with context:\n\nIssue: Vendor delay impacting timeline\n\nImpact: Risk to Q2 launch\n\nAction Items\nClear tasks with owners:\n\nTask: Approve revised budget\n\nOwner: Finance Team\n\nDeadline: EOD Friday\n\nFollow-Up Needed\nOpen questions or missing info:\n\n\"Confirm if the client approved the scope change?\"\n\nRules for Clarity\n\u2714 Be concise \u2013 1 line per point\n\u2714 Prioritize \u2013 Flag urgent items with [!]\n\u2714 Ownership \u2013 Always note who needs to act\n\u2714 Use plain language \u2013 Avoid jargon\n\nExample Output:\n\nSummary\n\nMarketing campaign paused due to budget review\n\nNew analytics tool rollout delayed by 2 weeks\n\nIssues\n\n[!] Budget approval missing \u2013 blocking all spend\n\nLow engagement on recent social posts\n\nActions\n\nSend revised budget to CFO (Owner: Alex)\n\nAudit social content (Owner: Marketing, Due: Nov 30)\n\nFollow-Up\n\nIs the budget review meeting scheduled?"
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "5b97bbf7-5259-4554-a81e-330494bdcc45",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1460,
        -160
      ],
      "parameters": {
        "width": 1960,
        "height": 860,
        "content": "# \ud83d\udce7 Email Auto-Summary Flow (n8n)\n\n**Purpose**: Daily digest of `isb.quantana@quantana.in` emails  \n**Runs**: 8AM IST (7AM UTC) weekdays  \n\n## \ud83d\udd04 Workflow\n1. \u23f0 **Trigger**: Scheduled daily run  \n2. \ud83d\udce5 **Input**: Fetch last 24h emails via Gmail API  \n3. \ud83e\udd16 **Process**:  \n   - Filter non-essential emails  \n   - Extract key metadata (sender, subject, body)  \n4. \u270d\ufe0f **AI Summary**:  \n   - Langchain analyzes content  \n   - Identifies: Updates/Issues/Actions  \n5. \ud83d\udce4 **Output**: Formatted email to team via Gmail API  \n\n## \ud83d\udd11 APIs Needed:\n- Gmail API (OAuth2)  \n- OpenRouter API (LLM access)  \n- (Optional) Slack API for alerts  \n\n## \u2699\ufe0f Config:\n- `OPENROUTER_KEY` for AI  \n- `GMAIL_CREDS` for email access  \n- Recipient list in flow vars  \n\n\ud83d\udca1 Processes ~50 emails/day | Error alerts via email"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "54b5fc42-b14e-4949-8b95-d956680caf69",
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Email Summarizer",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Email Summarizer": {
      "main": [
        [
          {
            "node": "Send Summary - Morning",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily 8AM Trigger": {
      "main": [
        [
          {
            "node": "Fetch Emails - Past 24 Hours",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Summarizer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Emails - Past 24 Hours": {
      "main": [
        [
          {
            "node": "Organize Email Data - Morning",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Organize Email Data - Morning": {
      "main": [
        [
          {
            "node": "Email Summarizer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}