Skip to main content

Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts

Workflow preview

Workflow preview
100%
Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Automated Gmail Labeling and Brainstorming 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 specifi...

Best for

  • Personal Productivity automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmailtrigger, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.gmail, n8n-nodes-base.aggregate, n8n-nodes-base.httprequest, n8n-nodes-base.wait, n8n-nodes-base.code

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by InfraNodus.

Original n8n.io source

1.1 Workflow description

Title
Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts
Workflow name
Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts

Automated Gmail Labeling and Brainstorming

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.

You can also get notified about the emails with the most important labels via Telegram as well as receive new ideas as you are building a knowledge graph of incoming messages.

The idea generation is based on the InfraNodus knowledge graph content gap detection algorithm, which builds a network from your content and then finds a blind spot and uses AI to generate an interesting research question or idea that can be used to bridge this gap.

Why it works so well?

Think of all the business emails you receive that bypass the spam filters. Probably, they are personalized to you already. Now imagine if you build a knowledge graph from them for over a month. You will then have a ideation device based on your interests and marketing profile. Now, if you identify the gaps inside and generate interesting research questions based on them, you will come up with new interesting ideas that will be relevant (because they touch on the topics that matter to you), but novel, because they bridge them in new ways.

What is it useful for?

  • Automate Gmail incoming message labeling with the new Classifier n8n node — much more advanced than the default Gmail labeling rules.
  • Get notified via Telegram (or a messenger of your choice) about the most important messages and be sure not to miss anything important.
  • Keep the messages with a certain label saved into knowledge graph for brainstorming and ideation.
  • Every time a new message of this category comes in, it's added into the graph, changing its structure, a new idea is generated. So instead of looking at each specific offer, you now use them to generate insights for you.

How it works

  • Step 1: This template can is triggered automatically when a new Gmail message arrives. Note: you need to connect your Gmail account here in this node

  • Step 2: We use the new n8n AI Classifier Node to classify your email based on its content. You might need to update to n8n 1.94 version to make it work. Note: we like to use Gemini AI for that classifier as it's the same company as Gmail, so should be safe with data

  • Step 3: After classifying the message, we label the message with the appropriate label. Note: you need to create the labels before in your Gmail account

  • Step 4: For a certain category (e.g. "Business" you format the message and save it into your InfraNodus graph. Note: specify your InfraNodus API here and choose the name of the graph. It will use the InfraNodus HTTP graphAndEntries endpoint and save your data to an InfraNodus graph. By default, we save the text knowledge graph using the contextSettings parameters (it will only build a text graph of the content), but you can take an alternative setting from this InfraNodus HTTP node's settings and create a social knowledge graph, that will also show email senders in the graph itself.

  • Step 5 (optional): Generate an interesting insight question with the graphAndAdvice endpoint of InfraNodus.

  • Step 6 (optional): Then send this insight via Telegram to a chat.

  • Step 7 (optional): Link some important labels to the second Telegram notification node, so you receive important messages for specified labels.

  • Step 8 (optional): Send a Telegram notification

We use Telegram, because it takes only 30 seconds to set up a bot with an API (send /newbot to @botfather, unlike Discord or Slack, which is long and cumbersome to set up. You can also attach a Gmail send node and generate an email instead.

How to use

You need an InfraNodus GraphRAG API account and key to use this workflow.

  • Create an InfraNodus account or log in.
  • Get the API key at https://infranodus.com/api-access and create a Bearer authorization key for the InfraNodus HTTP nodes.
  • Add this Authorization code in Steps 4 and 5 of the workflow.
  • Come up with the name of the graph and change it in the HTTP InfraNodus nodes in the steps 4 and 5 and also in the Telegram node in Step 6 that sends a link to the graph.
  • For additional text processing / idea generation settings you can use in the HTTP InfraNodus nodes, see the InfraNodus access points page. For example, in Step 4 you can change the text processing settings to build a social knowledge graph (settings are available in the Node's Notes section) and in Step 5 you can change the requestMode from question to idea to receive business ideas instead.
  • Authorize your Gmail account for Steps 2, 3, 7 and 8 Gmail nodes. The easiest way to set it up is to open a free Google Console API account and to create an OAuth access point for n8n. You can then reuse it with other Google services like Google Sheets, Drive, etc. So it's a useful thing to have in general.
  • Set up the Gemini AI API key using the instructions in the Step 2 Gemini AI classification node.
  • Set up the Telegram node bot for the Step 8. It takes only 30 seconds: just go to @botfather and type in /newbot and you'll have an API key ready. To get the conversation ID, follow the n8n / Telegram instructions in the node itself.
  • Once everything is ready, try to run the default automated workflow to test if everything works well.

Requirements

  • An InfraNodus account and API key
  • An Google Cloud API OAuth client and key for Gmail access
  • A Gemini AI API key
  • A Telegram bot API key
  • n8n version 1.94 and higher (for Text Classification AI node to work)

Customizing this workflow

Check our other n8n workflows at https://n8n.io/creators/infranodus/ for useful content gap analysis, expert panel, and marketing, and research workflows that utilize GraphRAG for better AI generation.

Finally, check out https://infranodus.com to learn more about our network analysis technology used to build knowledge graphs from text.

For support, please, contact https://support.noduslabs.com

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 6 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Label as Business

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 8 - Label as Personal

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 9 - Label as Urgent

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 10 - Label as Appointments

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 11 - Aggregate

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 12 - InfraNodus Save to Graph

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 13 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 15 - Clean html and organize into statements

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - InfraNodus Question Generator

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 17 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Get Label's Name in Gmail

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 19 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Send Insight to Telegram

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 21 - Send Notification via Telegram

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 22 - Label as Invoices

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 23 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 24 - Get Email's snippet

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Showing the first 24 of 28 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts
Complexity advanced
Nodes 28
Categories Personal Productivity, AI RAG
Author InfraNodus
Published 04 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4647/4647.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automate Gmail labeling with Gemini AI & build InfraNodus knowledge graph with Telegram alerts do?

Automated Gmail Labeling and Brainstorming 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 specifi...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Personal Productivity, AI RAG use case.