AutomationFlowsAI & RAG › Automate Gmail Labeling with Gemini AI & Build Infranodus Knowledge Graph…

Automate Gmail Labeling with Gemini AI & Build Infranodus Knowledge Graph…

Original n8n title: Automate Gmail Labeling with Gemini AI & Build Infranodus Knowledge Graph with Telegram Alerts

ByInfraNodus @infranodus on n8n.io

This template can be used to automatically label your incoming Gmail messages with AI and to build a knowledge graph from the emails tagged with a specific label to brainstorm new ideas based on them.

Event trigger★★★★☆ complexityAI-powered28 nodesGmail TriggerOpenAI ChatGmailHTTP RequestTelegramGoogle Gemini ChatText Classifier
AI & RAG Trigger: Event Nodes: 28 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #4647 — we link there as the canonical source.

This workflow follows the Gmail → Gmail Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "kuHROEwShNrG11Ea",
  "name": "Label Incoming Messages, Build a Knowledge Graph, Notify via Telegram",
  "tags": [
    {
      "id": "sJk9cUvmMU8FkJXv",
      "name": "AI",
      "createdAt": "2025-05-20T13:16:15.636Z",
      "updatedAt": "2025-05-20T13:16:15.636Z"
    },
    {
      "id": "E52i6BJ7Ht6yF3OB",
      "name": "Productivity",
      "createdAt": "2025-06-04T10:29:27.533Z",
      "updatedAt": "2025-06-04T10:29:27.533Z"
    },
    {
      "id": "66wgFoDi9Xjl74M3",
      "name": "Support",
      "createdAt": "2025-05-21T17:06:32.355Z",
      "updatedAt": "2025-05-21T17:06:32.355Z"
    }
  ],
  "nodes": [
    {
      "id": "ba46bc4c-7f6b-4482-ae2b-f1621695a0d4",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        100,
        1100
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": "-from:me"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "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"
      },
      "typeVersion": 1
    },
    {
      "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 settings.\n\nWe like using Gemini because it's run by the same company as Gmail, so you don't really expose more data than you need to other AIs. But you can use OpenAI if you don't mind."
      },
      "typeVersion": 1
    },
    {
      "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 important emails. \n\n\ud83d\udea8  You need to create these labels before in your Gmail mailbox"
      },
      "typeVersion": 1
    },
    {
      "id": "8b3d7ee8-7ef7-498a-a975-b578778f77d0",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "disabled": true,
      "position": [
        600,
        1420
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "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 up its name, and you'll get the API key to use here. Takes 30 seconds. "
      },
      "typeVersion": 1
    },
    {
      "id": "bd63f009-14b4-46c8-b7d7-c17eba11ea71",
      "name": "Label as Business",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1200
      ],
      "parameters": {
        "labelIds": [
          "Label_3466297294634862775"
        ],
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a887766-6e31-4719-878b-1df06aa537be",
      "name": "Label as Personal",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1440
      ],
      "parameters": {
        "labelIds": [
          "Label_8982059712942854310"
        ],
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "aa488bb4-8987-40b1-982f-d062e895dceb",
      "name": "Label as Urgent",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1860
      ],
      "parameters": {
        "labelIds": [
          "Label_7826865676723242579"
        ],
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "92180fdf-18c2-49d9-92ce-99fb0e0bffd7",
      "name": "Label as Appointments",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1660
      ],
      "parameters": {
        "labelIds": [
          "Label_912815023264112825"
        ],
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "65a404c8-b96c-4388-9b11-80c947c1ce88",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1800,
        1920
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "executeOnce": true,
      "typeVersion": 1
    },
    {
      "id": "3bbfb056-e76c-4321-91a1-364460b28f34",
      "name": "InfraNodus Save to Graph",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "// optional context setting to save a social knowledge graph\n{{{ \"partOfSpeechToProcess\":\"HASHTAGS_AND_WORDS\", \"doubleSquarebracketsProcessing\":\"PROCESS_AS_MENTIONS\"} }}",
      "position": [
        2360,
        1240
      ],
      "parameters": {
        "url": "https://infranodus.com/api/v1/graphAndStatements?doNotSave=false&includeGraph=false&includeGraphSummary=true&includeStatements=false",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "gmail_business"
            },
            {
              "name": "statements",
              "value": "={{ $json.statements }}"
            },
            {
              "name": "contextSettings",
              "value": "={{{ \"partOfSpeechToProcess\":\"HASHTAGS_AND_WORDS\", \"doubleSquarebracketsProcessing\":\"EXCLUDE\", \"mentionsProcessing\":\"EXCLUDE\"} }}"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "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 overview of the business offers you receive and generate some interesting ideas from them.\n\n\ud83d\udea8 The name of the graph is provided in the `name` field. It can be accessed any time if you log in via [infranodus.com/your_user_name/graph_name/edit](infranodus.com/your_user_name/graph_name/edit)\n\nBy default, we build a text knowledge graph (without the emails\u00a0on the graph). If you prefer to build just a social knowledge graph (with the emails), go to the node's Settings and copy the data in the `Notes` field to the `contextSettings` "
      },
      "typeVersion": 1
    },
    {
      "id": "a7361550-2fc9-4e71-b9b5-d4bbe678335a",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2800,
        1240
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "a0b4cb24-513e-4e51-8673-472a38cb2836",
      "name": "Clean html and organize into statements",
      "type": "n8n-nodes-base.code",
      "position": [
        1840,
        1240
      ],
      "parameters": {
        "jsCode": "\nlet statements = []\nfor (const item of $input.all()) {\n\n    const emailOrigin = $('Gmail Trigger').first().json.from.value[0].name\n    const cleanTextContent = removeHtmlCssScript($('Gmail Trigger').first().json.text)\n    statements.push('[[' + emailOrigin + ']] ' + '[' + $('Gmail Trigger').first().json.date?.split('T')[0] + '] ' + cleanTextContent)\n\n}\n\nreturn { statements: statements }\n\nfunction removeHtmlCssScript(text) {\n  if (!text || typeof text !== 'string') {\n    return '';\n  }\n  \n  let cleanText = text;\n  \n  // Remove script tags and their content (case insensitive)\n  cleanText = cleanText.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');\n  \n  // Remove style tags and their content (case insensitive)\n  cleanText = cleanText.replace(/<style[^>]*>[\\s\\S]*?<\\/style>/gi, '');\n  \n  // Remove HTML comments\n  cleanText = cleanText.replace(/<!--[\\s\\S]*?-->/g, '');\n  \n  // Remove all remaining HTML tags\n  cleanText = cleanText.replace(/<[^>]*>/g, '');\n  \n  // Decode common HTML entities\n  const htmlEntities = {\n    '&amp;': '&',\n    '&lt;': '<',\n    '&gt;': '>',\n    '&quot;': '\"',\n    '&#39;': \"'\",\n    '&nbsp;': ' ',\n    '&copy;': '\u00a9',\n    '&reg;': '\u00ae',\n    '&trade;': '\u2122'\n  };\n  \n  Object.keys(htmlEntities).forEach(entity => {\n    const regex = new RegExp(entity, 'g');\n    cleanText = cleanText.replace(regex, htmlEntities[entity]);\n  });\n  \n  // Clean up extra whitespace\n  cleanText = cleanText.replace(/\\s+/g, ' ').trim();\n  \n  return cleanText;\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "d55f464d-0d0f-4f17-9abb-948d43565309",
      "name": "InfraNodus Question Generator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3180,
        1240
      ],
      "parameters": {
        "url": "https://infranodus.com/api/v1/graphAndAdvice?doNotSave=true&optimize=gap&includeGraph=false&includeGraphSummary=true",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "aiTopics",
              "value": "true"
            },
            {
              "name": "requestMode",
              "value": "question"
            },
            {
              "name": "name",
              "value": "gmail_business"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "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 question based on all the previously saved information. \n\n\ud83d\udea8 Make sure to specify the correct graph name as in Step 4 in this step, in the `name` field. \n\n\ud83d\udea8 You can also replace the `requestMode` with `idea`, in which case you receive not a question, but an idea.\n\nYou can also do it manually using the Analytics > Content Gaps panel in the graph itself: [infranodus.com/your_user_name/graph_name/edit](infranodus.com/your_user_name/graph_name/edit)"
      },
      "typeVersion": 1
    },
    {
      "id": "cd621b22-b5d3-44af-9bed-ef83784140fb",
      "name": "Get Label's Name in Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2020,
        1920
      ],
      "parameters": {
        "labelId": "={{ $json.data[0].labelIds.find(label => label.includes('Label')) }}",
        "resource": "label",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "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"
      },
      "typeVersion": 1
    },
    {
      "id": "9ed340b9-a9ee-4844-af29-95d70e9f095d",
      "name": "Send Insight to Telegram",
      "type": "n8n-nodes-base.telegram",
      "onError": "continueRegularOutput",
      "position": [
        3760,
        1240
      ],
      "parameters": {
        "text": "=\ud83d\udcad Question: {{ $json.aiAdvice[0].text }} \nMore at [https://infranodus.com/your_user_name/gmail_business/edit](https://infranodus.com/your_user_name/gmail_business/edit)",
        "chatId": "",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1.2
    },
    {
      "id": "e11bc8c5-be6d-4208-a6d8-e6f7f3f0aac5",
      "name": "Send Notification via Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2480,
        1920
      ],
      "parameters": {
        "text": "=\ud83d\udcec Important email / Label: {{ $('Get Label\\'s Name in Gmail').item.json.name }} / Preview: \n{{ $('Gmail Trigger').item.json.subject }}: {{ $json.snippet }}\nRead more at https://mail.google.com/mail/u/0/#inbox/{{ $('Gmail Trigger').item.json.threadId }}",
        "chatId": "",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "bc44b63e-f26e-4431-a9b9-f222cbf1c0cb",
      "name": "Label as Invoices",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        2060
      ],
      "parameters": {
        "labelIds": [
          "Label_961995338561265835"
        ],
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "831683f8-1f8e-4007-bc18-2592df639b47",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        420,
        1420
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-04-17"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e10e2405-8c6d-4a55-bb20-bd0b87d0d767",
      "name": "Get Email's snippet",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2320,
        1920
      ],
      "parameters": {
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "53f9d6db-e981-4e6e-8a59-c8fc67821dbc",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 6,
        "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 save emails for selected categories to an [InfraNodus knowledge graph](https://infranodus.com) to have a visual summary of your content, then get notified via Telegram with an insight question based on this new input. \n\n \n![InfraNodus Graph](https://infranodus.com/images/front/infranodus-overview@2x.jpg)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "64f8c1b0-9194-4aed-8822-0173f93e41d3",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        0
      ],
      "parameters": {
        "color": 5,
        "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 the Step 2\n\n4. Add your Gemini API key in Step 2 (or OpenAI if you prefer)\n\n5. Add your [InfraNodus API](https://infranodus.com/api-access) creddentials in the Step 4 and Step 6.\n\n6. Optionally: change the `requestMode` to `idea` in the Step 5 if you prefer to receive ideas and not research questions.\n\n7. Choose which label category you want to be saved to your InfraNodus graph\n\n7. Optionally: choose which label category emails you want to be notified immediately about. Link them to the Step 7\n\n8. Optionally: add Telegram credentials if you want to be notified of a certain category emails via Telegram\n\n\nFor support, please, contact [https://support.noduslabs.com](https://support.noduslabs.com)\n\nTo open an InfraNodus account: [https://infranodus.com](https://infranodus.com)\n\n"
      },
      "typeVersion": 1
    },
    {
      "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, appointments, and urgent emails.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fc1d740a-8163-4c62-ba00-3737c292fa47",
      "name": "Text Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        420,
        1220
      ],
      "parameters": {
        "options": {
          "multiClass": true
        },
        "inputText": "=Subject: {{ $json.subject }}\nMessage:\n{{ $json.text }} ",
        "categories": {
          "categories": [
            {
              "category": "Business",
              "description": "Business-related messages, including interesting offers, personalized partnership requests or opportunities. Avoid automated messages."
            },
            {
              "category": "Personal",
              "description": "Personal emails that are addressed to me directly, from friends, acquaintances, or very personal tone, not spam Avoid automated messages."
            },
            {
              "category": "Appointments",
              "description": "Important appointments and scheduled arrangements that should be in a calendar."
            },
            {
              "category": "Urgent",
              "description": "Things that should be attended urgently, avoid automated messages."
            },
            {
              "category": "Invoices",
              "description": "Emails that contain an invoice with a payment amount"
            }
          ]
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "cbebe7e2-cba3-4f86-9361-74ea100639b0",
  "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
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template can be used to automatically label your incoming Gmail messages with AI and to build a knowledge graph from the emails tagged with a specific label to brainstorm new ideas based on them.

Source: https://n8n.io/workflows/4647/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Check out this channel for example.

Gmail, OpenAI Chat, Gmail Trigger +3
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16
AI & RAG

This n8n template demonstrates how to automate email classification, labeling, draft generation, and logging using Gmail, OpenAI, and Google Sheets. Use cases include customer support management, sale

Gmail Trigger, Gmail, Text Classifier +4
AI & RAG

This n8n template uses AI to automatically classify incoming Gmail messages into five categories and route them to the right people or departments. It can also reply automatically and send WhatsApp al

Gmail Trigger, OpenAI Chat, Gmail +3
AI & RAG

Detects new unread Gmail messages Extracts sender name for personalized replies Classifies the email into one of four categories Applies the correct Gmail label and either sends an auto-reply, creates

Gmail Trigger, OpenAI Chat, Gmail +4