Skip to main content

Intelligent Gmail label management with AI & Discord notifications

Workflow preview

Workflow preview
100%
Intelligent Gmail label management with AI & Discord notifications preview
Open on n8n.io

Important notice

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

1. Workflow Overview

How it works This workflow will trigger upon new mail in your gmail inbox and will automatically apply existing labels OR identify, create, then apply up to 5 new labels. This is currently set up t...

Best for

  • Ticket Management automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.chainllm, n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.gmail, n8n-nodes-base.code, n8n-nodes-base.merge, n8n-nodes-base.splitout, n8n-nodes-base.discord

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Intelligent Gmail label management with AI & Discord notifications
Workflow name
Intelligent Gmail label management with AI & Discord notifications

How it works

  • This workflow will trigger upon new mail in your gmail inbox and will automatically apply existing labels OR identify, create, then apply up to 5 new labels.
  • This is currently set up to run using a OpenAI endpoint which I have set up connected to my local llama.cpp server running.
  • After your email is done labeling, the workflow will send you a nice notification in your discord channel!

Set up Instructions

  • This workflow requires a Gmail OAuth account credential with the ability to create labels and label messages
  • [OPTIONAL] You can create a Discord Bot Account which connects with a Bot Token which will summarize the email and show you which labels were created and added in the workflow.
  • You might want to tweak the prompts a bit based on how detailed you want your labels. I've found after running it for a bit that the labels that get created mostly encompass everything I want.

Workflow Hints

  • The workflow works in 5 phases -- Phase 1: Find existing Gmail labels as options for the LLM to choose from. -- Phase 2: LLM chooses labels or defines new ones -- Phase 3: Create additional Gmail labels if needed -- Phase 4: Label the message with newly created and existing labels -- Phase 5: Rewrite and send a message notification via Discord.

Screenshot 1: Note: colors are my own

Screenshot of notification sent via discord

Model Tips

  • I set this up to run completely using offline models. I had good success with Llama.cpp server with gpt-oss-20B and with a bit more tweaking could get it to work with a smaller gemma3-4b model mostly likely as well.
  • The whole workflow runs in about 5-10 seconds on my Blackwell Nvidia GPU. Probably would be a few seconds slower on an older piece of hardware.

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 - Basic LLM Chain

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 2 - Gmail Trigger

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

Block 3 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 4 - Create a label

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

Block 5 - Code

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

Block 6 - Merge2

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 7 - Split Out

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

Block 8 - Merge3

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 9 - Add label to message

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

Block 10 - Send a message

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

Block 11 - Get many labels

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

Block 12 - Filter

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 13 - Aggregate1

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

Block 14 - Aggregate2

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

Block 15 - Edit Fields3

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 16 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 17 - OpenAI Chat 10001

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

Block 18 - OpenAI Chat 10000

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

Block 19 - Basic LLM Chain1

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.7

Block 20 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 21 - Sticky Note1

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

Block 22 - Sticky Note2

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

Block 23 - Sticky Note3

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

Block 24 - Sticky Note

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

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

3. Summary Table

Workflow Intelligent Gmail label management with AI & Discord notifications
Complexity advanced
Nodes 27
Categories Ticket Management, AI Summarization
Author Albert Ho
Published 31 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8080/8080.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 Intelligent Gmail label management with AI & Discord notifications do?

How it works This workflow will trigger upon new mail in your gmail inbox and will automatically apply existing labels OR identify, create, then apply up to 5 new labels. This is currently set up t...

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 Ticket Management, AI Summarization use case.