{
  "name": "Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts",
  "nodes": [
    {
      "id": "ba46bc4c-7f6b-4482-ae2b-f1621695a0d4",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        100,
        1100
      ]
    },
    {
      "id": "e8be32bf-2bb6-491a-8aba-a62efad5398d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        900
      ],
      "parameters": {
        "width": 304.10628068244364,
        "height": 394.42512272977456,
        "content": "## 1. When a new message arrives to your GMail inbox, trigger this workflow\n\n"
      }
    },
    {
      "id": "43f13337-45f6-4485-b8b0-ec868340b168",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        900
      ],
      "parameters": {
        "width": 456,
        "height": 697,
        "content": "## 2. Classify the email by the topic\n\n### Specify the label types and descriptions in the Classifier Node.\n\nBy default, multiple labels can be applied, but you can switch this off in the node's setti"
      }
    },
    {
      "id": "996d2cdd-a6b8-4e93-9d7a-4d6a63120107",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        900
      ],
      "parameters": {
        "width": 786,
        "height": 1315,
        "content": "## 3. Label the message with an appropriate tag\n\n### It will stay in the Inbox folder, but will also be stored in the Label folder, so you can have easy access to it to make sure you don't miss out on"
      }
    },
    {
      "id": "8b3d7ee8-7ef7-498a-a975-b578778f77d0",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        600,
        1420
      ]
    },
    {
      "id": "911e7892-5219-47b0-84d7-cc931b3b1cf9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2260,
        1600
      ],
      "parameters": {
        "width": 366,
        "height": 555,
        "content": "## Optional: 8. Notify via Telegram\n\n\n### Get notified about the most important messages on Telegram\n\nTo get the Telegram bot API, just start a chat with the [@botfather](https://t.me/botfather), set "
      }
    },
    {
      "id": "bd63f009-14b4-46c8-b7d7-c17eba11ea71",
      "name": "Label as Business",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1200
      ]
    },
    {
      "id": "0a887766-6e31-4719-878b-1df06aa537be",
      "name": "Label as Personal",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1440
      ]
    },
    {
      "id": "aa488bb4-8987-40b1-982f-d062e895dceb",
      "name": "Label as Urgent",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1860
      ]
    },
    {
      "id": "92180fdf-18c2-49d9-92ce-99fb0e0bffd7",
      "name": "Label as Appointments",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1660
      ]
    },
    {
      "id": "65a404c8-b96c-4388-9b11-80c947c1ce88",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1800,
        1920
      ]
    },
    {
      "id": "3bbfb056-e76c-4321-91a1-364460b28f34",
      "name": "InfraNodus Save to Graph",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2360,
        1240
      ]
    },
    {
      "id": "4b0620da-8be4-4cd1-883d-08ec95d9cf5d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1740,
        900
      ],
      "parameters": {
        "width": 886,
        "height": 515,
        "content": "## 4. Save message with the \"business\" label (or a label you choose) into a specific [InfraNodus](https://infranodus.com) knowledge graph\n\n### You can access the graph any time to have a general overv"
      }
    },
    {
      "id": "a7361550-2fc9-4e71-b9b5-d4bbe678335a",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2800,
        1240
      ]
    },
    {
      "id": "a0b4cb24-513e-4e51-8673-472a38cb2836",
      "name": "Clean html and organize into statements",
      "type": "n8n-nodes-base.code",
      "position": [
        1840,
        1240
      ]
    },
    {
      "id": "d55f464d-0d0f-4f17-9abb-948d43565309",
      "name": "InfraNodus Question Generator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3180,
        1240
      ]
    },
    {
      "id": "fbdca5de-9e84-4563-ad88-09130e260e5a",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2720,
        900
      ],
      "parameters": {
        "width": 686,
        "height": 515,
        "content": "## Optional: 5. Generate an interesting insight question based on the graph, after that message is received.\n\n### After the new message is saved, query the graph to generate an interesting insight que"
      }
    },
    {
      "id": "cd621b22-b5d3-44af-9bed-ef83784140fb",
      "name": "Get Label's Name in Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2020,
        1920
      ]
    },
    {
      "id": "2fb4e4fa-cd1b-4dd4-a12e-16af50bf1561",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3500,
        900
      ],
      "parameters": {
        "width": 686,
        "height": 515,
        "content": "## 6. Optional: Send a new insight question to the Telegram chat\n\n### Send the new insight question to the Telegram chat\n\nYou can also send it to Discord or email or save it to a Google sheets file"
      }
    },
    {
      "id": "9ed340b9-a9ee-4844-af29-95d70e9f095d",
      "name": "Send Insight to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3760,
        1240
      ]
    },
    {
      "id": "e11bc8c5-be6d-4208-a6d8-e6f7f3f0aac5",
      "name": "Send Notification via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2480,
        1920
      ]
    },
    {
      "id": "bc44b63e-f26e-4431-a9b9-f222cbf1c0cb",
      "name": "Label as Invoices",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        2060
      ]
    },
    {
      "id": "831683f8-1f8e-4007-bc18-2592df639b47",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        420,
        1420
      ]
    },
    {
      "id": "e10e2405-8c6d-4a55-bb20-bd0b87d0d767",
      "name": "Get Email's snippet",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2320,
        1920
      ]
    },
    {
      "id": "53f9d6db-e981-4e6e-8a59-c8fc67821dbc",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 824,
        "height": 874,
        "content": "# Label Incoming Messages with AI, Build a Knowledge Graph for Selected Categories, then Notify via Telegram with a Insight for all Emails in Category\n\n## Automatically label your email using AI and s"
      }
    },
    {
      "id": "64f8c1b0-9194-4aed-8822-0173f93e41d3",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        0
      ],
      "parameters": {
        "width": 524,
        "height": 574,
        "content": "## Setup Guide\n\n### To activate this workflow, you'll need to\n\n1. Create the labels you want to use in your Gmail account\n\n2. Set these labels in Step 3\n\n3. Describe how categorization should occur in"
      }
    },
    {
      "id": "fc23ec5f-7bc5-487f-8a3f-1b84846e9af8",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1720,
        1600
      ],
      "parameters": {
        "width": 466,
        "height": 555,
        "content": "## Optional: 7. Choose which emails you want to be notified immediately about\n\n\n### Link this node to the labels you want to be notified immediately about.\n\nI like to be notified of the personal, appo"
      }
    },
    {
      "id": "fc1d740a-8163-4c62-ba00-3737c292fa47",
      "name": "Text Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        420,
        1220
      ]
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "InfraNodus Question Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Get Label's Name in Gmail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label as Urgent": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "Label as Business",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label as Personal",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label as Appointments",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label as Urgent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Label as Invoices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label as Business": {
      "main": [
        [
          {
            "node": "Clean html and organize into statements",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label as Personal": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Email's snippet": {
      "main": [
        [
          {
            "node": "Send Notification via Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Label as Appointments": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "InfraNodus Save to Graph": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Label's Name in Gmail": {
      "main": [
        [
          {
            "node": "Get Email's snippet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "InfraNodus Question Generator": {
      "main": [
        [
          {
            "node": "Send Insight to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean html and organize into statements": {
      "main": [
        [
          {
            "node": "InfraNodus Save to Graph",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}