{
  "name": "Basic automatic Gmail email labelling with OpenAI and Gmail API",
  "nodes": [
    {
      "id": "2a41e2da-19f7-4c31-ab93-3a534db3179e",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -360,
        -260
      ]
    },
    {
      "id": "a25e0e42-8eab-49c5-a553-797da40eb623",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -220,
        -60
      ]
    },
    {
      "id": "cf437748-a0df-42a2-b1ca-f93162d85bfe",
      "name": "Gmail - read labels",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        80,
        -40
      ]
    },
    {
      "id": "152f1970-7a1f-4977-9c21-64b69242d3a9",
      "name": "Gmail - get message",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        260,
        -40
      ]
    },
    {
      "id": "ae09cedc-9675-4080-bcdc-3d6c4e4bc490",
      "name": "Gmail - add label to message",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        460,
        -40
      ]
    },
    {
      "id": "be4a92ab-d3ab-451b-8655-172851f68628",
      "name": "Gmail - create label",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        640,
        -40
      ]
    },
    {
      "id": "a40466d2-2fe3-4a97-98fe-b14cc38cc141",
      "name": "Gmail labelling agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -60,
        -260
      ]
    },
    {
      "id": "6b514df4-761c-4072-abf8-d572ee4b8030",
      "name": "Window Buffer Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -60,
        -40
      ]
    },
    {
      "id": "f06717ed-00d7-4a99-a78c-53217a0067e7",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -220,
        -260
      ]
    },
    {
      "id": "f6084fc3-2b6b-488f-b212-f179435e1a63",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -300
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": "## Gmail trigger\nPoll Gmail every x minutes, trigger when a new email is received.\n\n- Gmail API"
      }
    },
    {
      "id": "5ede55a4-52ae-48c0-969e-afa45d19f2f0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -960
      ],
      "parameters": {
        "width": 780,
        "height": 840,
        "content": "## Gmail labelling agent\n- Read the message\n- Read existing labels\n- Create a new label if needed\n- Assign label to message\n\n----\n\nObjective:\nAutomatically categorize incoming emails based on existing"
      }
    },
    {
      "id": "7c8bb6de-b729-4c8e-90c2-641d173ed3dd",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        160
      ],
      "parameters": {
        "width": 440,
        "height": null,
        "content": "## Gmail API\n- Add credentials "
      }
    },
    {
      "id": "e9d05013-9546-426f-bdc7-45199dbfc72a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        80
      ],
      "parameters": {
        "width": 440,
        "height": null,
        "content": "## OpenAI\n- Add credentials "
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - get message": {
      "ai_tool": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - read labels": {
      "ai_tool": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - create label": {
      "ai_tool": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - add label to message": {
      "ai_tool": [
        [
          {
            "node": "Gmail labelling agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}