Add AI labels to Gmail messages
Configured with Aggregate, Chain LLM, Gmail, Gmail Trigger, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- Trigger
- Messaging
- Transform
- AI & models
Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.
Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.
How it works
The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.
| Node | Category | Type | Operation |
|---|---|---|---|
| Gmail trigger | Trigger | Gmail Trigger | See node parameters |
| Get message content | Messaging | Gmail | get |
| Set label values | Transform | Edit Fields | See node parameters |
| Get all labels | Messaging | Gmail | label |
| Split out assigned labels | Transform | Split Out | See node parameters |
| Merge corresponding labels | Transform | Merge | See node parameters |
| Aggregate label IDs | Transform | Aggregate | See node parameters |
| Add labels to message | Messaging | Gmail | addLabels |
| Assign labels for message | AI & models | Chain LLM | See node parameters |
| JSON Parser | Transform | Output Parser Structured | See node parameters |
| OpenAI Chat | AI & models | OpenAI Chat Model | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8n’s credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.
Requirements
An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.
Credential types declared in the source
gmailOAuth2openAiApi
Workflow notes
Add AI labels to Gmail messages
Add AI labels to Gmail messages
With this workflow you can automatically set labels for your Gmail message according to its content.
In this workflow available are 3 labels: "Partnership", "Inquiry" and "Notification". Feel free to adjust labels according to your needs.
Please remember to set label names both in your Gmail account and workflow.
⚠️ Note
⚠️ Note
- Complete video guide for this workflow is available on my YouTube.
- Remember to add your credentials and configure nodes (covered in the video guide).
- If you like this workflow, please subscribe to my YouTube channel and/or my newsletter.
Thank you for your support!
Gmail Trigger
Gmail Trigger
Receive data from Gmail about new incoming message.
⚠️ Set polling interval according to your needs.
### JSON schema
JSON schema
Edit JSON schema and label names according to your needs.
⚠️ Label names in system prompt and JSON schema should be the same.
Merge labels
Merge labels
Combine labels retrieved from Gmail account and assigned by AI together.
Aggregarte labels and add to message
Aggregarte labels and add to message
Create array of label IDs and add to the desired email message in Gmail.
Get message content
Get message content
Based on Gmail message ID retrieve body content of the email and pass it to AI chain.
Assign labels
Assign labels
Let the AI decide which labels suit the best content of the message.
⚠️ Remember to edit system prompt - modify label names and instructions according to your needs.
Add AI labels to Gmail messages
Add AI labels to Gmail messages
Purpose and structure
This folder contains the Add AI labels to Gmail messages workflow. Its executable nodes use aggregate, chainLlm, gmail, gmailTrigger, lmChatOpenAi, merge, outputParserStructured, set, splitOut. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.
Setup
Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.
Entry points
Gmail trigger
Verification
Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.
Attribution
https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Aggregate/1324_Aggregate_Gmail_Send_Triggered.json MIT; preserve source notices.