{
  "name": "Label Gmail inbox emails with GPT-4o and store them in Mem0",
  "nodes": [
    {
      "id": "cd25c3eb-6443-4f3a-aae6-8eb1a6653793",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1376,
        32
      ]
    },
    {
      "id": "4ee69624-759c-458f-854c-bbc576c219da",
      "name": "[Trigger]: Watch Inbox (5m)",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1792,
        -800
      ]
    },
    {
      "id": "1db47fcd-8642-4d88-a1cd-d0b8e35895cf",
      "name": "[Batch]: Process Emails",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1344,
        -800
      ]
    },
    {
      "id": "f89945ad-4001-47ae-bd18-722c50db5b4d",
      "name": "[Filter]: Needs Marketing Tag?",
      "type": "n8n-nodes-base.filter",
      "position": [
        -496,
        -1280
      ]
    },
    {
      "id": "86443994-0b91-432c-a5d0-2ff6ace45139",
      "name": "[Gmail]: Tag as Marketing",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -272,
        -1280
      ]
    },
    {
      "id": "8e7cc9d9-3fd6-41b3-8a3f-21e7add6d406",
      "name": "[LLM]: GPT-4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -784,
        -448
      ]
    },
    {
      "id": "8a2ddd22-dfef-4271-ac74-8648647cf7f2",
      "name": "[LLM]: Mistral",
      "type": "@n8n/n8n-nodes-langchain.lmChatMistralCloud",
      "position": [
        1008,
        -576
      ]
    },
    {
      "id": "93a675b2-7f80-4f02-a3dd-53d072528d99",
      "name": "[API]: Jigsaw Classification",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -464,
        -448
      ]
    },
    {
      "id": "ed2ffedc-5949-4bf3-84cf-871a038f6210",
      "name": "[Gmail]: Apply AI Category",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -304,
        -640
      ]
    },
    {
      "id": "59a2e00a-c086-46e7-827b-c2ef5842198b",
      "name": "[Gmail]: Apply Jigsaw Category",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -288,
        -448
      ]
    },
    {
      "id": "84604d20-efbf-407f-ab23-1cf35d49132b",
      "name": "[Set]: Finalize Payload Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -48,
        -576
      ]
    },
    {
      "id": "51107df5-f47f-4419-91f5-4c451bedb039",
      "name": "[Python]: Format Mem0 V2 Schema",
      "type": "n8n-nodes-base.code",
      "position": [
        176,
        -560
      ]
    },
    {
      "id": "3596baf1-0b05-49bf-bd18-d6a0403e96fe",
      "name": "[API]: Push to Mem0 Long-term",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        352,
        -400
      ]
    },
    {
      "id": "3a408ec1-7f8e-423e-8230-312b0e6ce653",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2592,
        -1168
      ],
      "parameters": {
        "width": 688,
        "height": 1072,
        "content": "\n## What This Workflow Does\nWIth this workflow you get instant email management. Correct labels for every incoming emails so you won't waste time scanning through your inbox.  \n\n\n#### This workflow is"
      }
    },
    {
      "id": "ca702056-6f59-41bb-9670-669b30e42949",
      "name": "[JS]: Sanitize & Detect Marketing",
      "type": "n8n-nodes-base.code",
      "position": [
        -1568,
        -800
      ]
    },
    {
      "id": "56c33cfb-284e-4db5-85d6-a8fbe7ac7577",
      "name": "[Router]: Triage Streams",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1072,
        -800
      ]
    },
    {
      "id": "aade7b21-1e45-4297-85e1-0f45e6ae7615",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -1488
      ],
      "parameters": {
        "width": 832,
        "height": 464,
        "content": "## The filter node is optional and can be deleted , keep if you already have filters active in Gmail.\n"
      }
    },
    {
      "id": "3437d9fe-06c2-459f-91a0-72ba831bc701",
      "name": "[AI]: Main Branch Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        -848,
        -624
      ]
    },
    {
      "id": "fd9fe8ee-e049-4fdf-9bdb-18861ffa63bc",
      "name": "[AI]: Internal Branch Extractor",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        944,
        -800
      ]
    },
    {
      "id": "3494f440-809c-44ed-8b7c-a209161cbfd3",
      "name": "[Gmail]: Tag Domain (Always runs first. Tags it as \"Agentive Concepts\")",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1296,
        -832
      ]
    },
    {
      "id": "611c848f-e744-4a71-b259-65b5da6dcfd4",
      "name": "[Gmail]: Apply category for branch",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1296,
        -608
      ]
    },
    {
      "id": "f65d9862-47d3-491e-828e-46fbf34d2794",
      "name": "End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -1184,
        -912
      ]
    },
    {
      "id": "08119c21-0076-4877-a7ae-952f17b548b8",
      "name": "Optional Branch",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1520,
        -688
      ]
    },
    {
      "id": "7717e2d6-e7f6-4e1f-8b7b-78a9cf1f6122",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -1104
      ],
      "parameters": {
        "width": 848,
        "height": 672,
        "content": "## THIS is OPTIONAL\nKeep ONLY if you run email addresses - for example when you are running a side hustle and need other extraction rules.\n\nWhen you decide to activate this branch just link it back to"
      }
    },
    {
      "id": "e5f8e49a-300d-43ae-81b6-cf6263a8c87f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        -512
      ],
      "parameters": {
        "width": 304,
        "height": 144,
        "content": "## Your Main Prompt \nAdd or delete categories as you see fit.\n\nexample is \"SAP lead\"  + short instruction \n\n\n\n "
      }
    },
    {
      "id": "2e158043-dce6-4295-8787-41258cddcb7a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        -80
      ],
      "parameters": {
        "width": 960,
        "height": 352,
        "content": "## Set up your labels (simple way)\n"
      }
    },
    {
      "id": "00e117d6-a550-4408-81d9-c37c9d9e0564",
      "name": "Check Success",
      "type": "n8n-nodes-base.if",
      "position": [
        -656,
        32
      ]
    },
    {
      "id": "81c268da-c7aa-492d-b1dd-e3df952acf84",
      "name": "Success Summary",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        -48
      ]
    },
    {
      "id": "9e75db3d-8877-476a-8709-74be3e7b7996",
      "name": "Error Details",
      "type": "n8n-nodes-base.code",
      "position": [
        -400,
        144
      ]
    },
    {
      "id": "56f324a0-4ba1-4af9-90b7-a5dae4a323dc",
      "name": "SETUP LIST",
      "type": "n8n-nodes-base.set",
      "position": [
        -1088,
        32
      ]
    },
    {
      "id": "c33c7d66-aa79-47f7-a4b0-f71bd8da9a90",
      "name": "Split Labels",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -944,
        32
      ]
    },
    {
      "id": "91aab9a8-f1b8-4917-9024-ee007b48817d",
      "name": "Create Gmail Simple",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -816,
        32
      ]
    }
  ],
  "connections": {
    "End": {
      "main": [
        []
      ]
    },
    "SETUP LIST": {
      "main": [
        [
          {
            "node": "Split Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Labels": {
      "main": [
        [
          {
            "node": "Create Gmail Simple",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Success": {
      "main": [
        [
          {
            "node": "Success Summary",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[LLM]: GPT-4o": {
      "ai_languageModel": [
        [
          {
            "node": "[AI]: Main Branch Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "SETUP LIST",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[LLM]: Mistral": {
      "ai_languageModel": [
        [
          {
            "node": "[AI]: Internal Branch Extractor",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Optional Branch": {
      "main": [
        []
      ]
    },
    "Create Gmail Simple": {
      "main": [
        [
          {
            "node": "Check Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Batch]: Process Emails": {
      "main": [
        [
          {
            "node": "End",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "[Router]: Triage Streams",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Router]: Triage Streams": {
      "main": [
        [
          {
            "node": "[Filter]: Needs Marketing Tag?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "[AI]: Internal Branch Extractor",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "[AI]: Main Branch Extractor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Gmail]: Tag as Marketing": {
      "main": [
        [
          {
            "node": "[Batch]: Process Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Gmail]: Apply AI Category": {
      "main": [
        [
          {
            "node": "[Set]: Finalize Payload Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[AI]: Main Branch Extractor": {
      "main": [
        [
          {
            "node": "[Gmail]: Apply AI Category",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "[API]: Jigsaw Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Trigger]: Watch Inbox (5m)": {
      "main": [
        [
          {
            "node": "[JS]: Sanitize & Detect Marketing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[API]: Jigsaw Classification": {
      "main": [
        [
          {
            "node": "[Gmail]: Apply Jigsaw Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[API]: Push to Mem0 Long-term": {
      "main": [
        [
          {
            "node": "[Batch]: Process Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Filter]: Needs Marketing Tag?": {
      "main": [
        [
          {
            "node": "[Gmail]: Tag as Marketing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Gmail]: Apply Jigsaw Category": {
      "main": [
        [
          {
            "node": "[Set]: Finalize Payload Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Set]: Finalize Payload Fields": {
      "main": [
        [
          {
            "node": "[Python]: Format Mem0 V2 Schema",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[AI]: Internal Branch Extractor": {
      "main": [
        [
          {
            "node": "[Gmail]: Apply category for branch",
            "type": "main",
            "index": 0
          },
          {
            "node": "[Gmail]: Tag Domain (Always runs first. Tags it as \"Agentive Concepts\")",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Python]: Format Mem0 V2 Schema": {
      "main": [
        [
          {
            "node": "[API]: Push to Mem0 Long-term",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[JS]: Sanitize & Detect Marketing": {
      "main": [
        [
          {
            "node": "[Batch]: Process Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Gmail]: Apply category for branch": {
      "main": [
        [
          {
            "node": "Optional Branch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "[Gmail]: Tag Domain (Always runs first. Tags it as \"Agentive Concepts\")": {
      "main": [
        [
          {
            "node": "Optional Branch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}