{
  "name": "Ai-powered Gmail email organization with auto-archiving and priority labels",
  "nodes": [
    {
      "id": "43e68fe1-7f48-4bc9-b19a-66d39bee5bbd",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -520,
        20
      ]
    },
    {
      "id": "32aa401a-60c3-4436-94d5-5ba09d3be6ae",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        80,
        0
      ]
    },
    {
      "id": "f6d325b4-ff87-4bba-9f27-b68590c8a533",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -520,
        -220
      ]
    },
    {
      "id": "8e10c622-9bf8-414b-8364-185c5c4808a0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -600,
        -480
      ],
      "parameters": {
        "width": 1660,
        "height": 680,
        "content": "## Mail Agent\nFor emails in the inbox, archive those that are completely unnecessary, and label the rest based on their relevance.\n\n"
      }
    },
    {
      "id": "2e664cd4-37af-4b8f-84a5-ff07911b8aaa",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -380
      ],
      "parameters": {
        "width": 180,
        "height": 360,
        "content": "### Trigger\nRun by communicating with Telegram"
      }
    },
    {
      "id": "966af8d0-bfca-40fa-b97c-ec1bb7de82d2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        -380
      ],
      "parameters": {
        "width": 180,
        "height": 360,
        "content": "### Get Mail via Gmail\nRetrieve all emails in the Gmail inbox.\n(Inbox = Label: INBOX)"
      }
    },
    {
      "id": "07dabeda-a075-4e45-9ecf-9a0e6d0df0b2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -380
      ],
      "parameters": {
        "width": 180,
        "height": 360,
        "content": "### Filter\nFilter out emails that have already been processed to avoid unnecessary work for the AI.\n\n"
      }
    },
    {
      "id": "b9a96646-283e-4328-8c79-57befa97bb69",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        -380
      ],
      "parameters": {
        "width": 980,
        "height": 540,
        "content": "### AI Agent\nCheck each email one by one, categorize them as necessary or unnecessary according to the provided prompt, and instruct Gmail to apply the appropriate labels."
      }
    },
    {
      "id": "32c73c57-61b5-430b-a011-f0b44fa2b226",
      "name": "mail_label_setter",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        360,
        0
      ]
    },
    {
      "id": "7cf38850-939c-4c8e-af62-1f730d5b7e34",
      "name": "mail_archiver",
      "type": "n8n-nodes-base.gmailTool",
      "position": [
        220,
        0
      ]
    },
    {
      "id": "5fab497e-a632-4565-8048-7ae9b209728d",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        380,
        -220
      ]
    },
    {
      "id": "f7144884-6ba6-4e97-be35-f5f8b27d56ad",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        820,
        -220
      ]
    },
    {
      "id": "9236fbc1-ffad-4bf0-b3a1-5d389e5b422c",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        520,
        0
      ]
    },
    {
      "id": "e0ec10ca-ad72-4784-891e-5bd5bcff7082",
      "name": "Reporter",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        520,
        -220
      ]
    },
    {
      "id": "9b4f8e14-7b9c-45b3-97cb-32f2fe756440",
      "name": "Get mails in INBOX",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -320,
        -220
      ]
    },
    {
      "id": "13088de9-6f96-463e-bcb6-92f97d7144d9",
      "name": "Filter processed",
      "type": "n8n-nodes-base.filter",
      "position": [
        -120,
        -220
      ]
    },
    {
      "id": "317ea413-e8fd-4148-8115-8b4d2b9a7fe4",
      "name": "Categoriser",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        80,
        -220
      ]
    }
  ],
  "connections": {
    "Reporter": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Reporter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Categoriser": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "mail_archiver": {
      "ai_tool": [
        [
          {
            "node": "Categoriser",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Filter processed": {
      "main": [
        [
          {
            "node": "Categoriser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Get mails in INBOX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "mail_label_setter": {
      "ai_tool": [
        [
          {
            "node": "Categoriser",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get mails in INBOX": {
      "main": [
        [
          {
            "node": "Filter processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Categoriser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Reporter",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Get mails in INBOX",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}