Gmail labelling agent
Configured with Agent, Gmail Tool, Gmail Trigger, OpenAI Chat Model, and additional nodes. Review the connections and setup before adapting this template.
Node categories in this workflow
- Trigger
- AI & models
- Messaging
- Data store
- Wait
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 |
| OpenAI Chat Model1 | AI & models | OpenAI Chat Model | See node parameters |
| Gmail - read labels | Messaging | Gmail Tool | label |
| Gmail - get message | Messaging | Gmail Tool | get |
| Gmail - add label to message | Messaging | Gmail Tool | addLabels |
| Gmail - create label | Messaging | Gmail Tool | label / create |
| Gmail labelling agent | AI & models | Agent | See node parameters |
| Window Buffer Memory | Data store | Memory Buffer Window | See node parameters |
| Wait | Wait | Wait | 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
Gmail labelling agent
Objective: Automatically categorize incoming emails based on existing Gmail labels or create a new label if none match.
Tools:
- Get message
- Read all labels
- Create label
- Assign label to message
Instructions:
Label Matching:
Analyze the email's subject, sender, recipient, keywords, and content. Compare with existing Gmail labels to find the most relevant match. Label Assignment:
Assign the email to the most appropriate existing label.` Remove the inbox label if the email is of less importance (like ads, promotions, aka "Reclame"), keep normal and important emails in the inbox. If no suitable label exists, create a new label based on the existing labels. Try reusing existing labels as much as possible. Always create a label as a sublabel, if no label applies, if the main label already exists, create the new label under the existing label, if no main label exists, create the label AI and create the new label under this label. Label Creation:
Ensure new labels align with the structure of existing ones, including capitalization, delimiters, and prefixes. Examples:
If the email subject is "Project Alpha Update," assign to [Project Alpha] if it exists. For "New Vendor Inquiry," create "Vendor Inquiry" if no relevant label exists. Outcome: Emails are consistently categorized under the appropriate or newly created labels, maintaining Gmail's organizational structure.
Gmail trigger
Gmail trigger
Poll Gmail every x minutes, trigger when a new email is received.
- Gmail API
Gmail labelling agent
Gmail labelling agent
- Read the message
- Read existing labels
- Create a new label if needed
- Assign label to message
Objective: Automatically categorize incoming emails based on existing Gmail labels or create a new label if none match.
Tools:
- Get message
- Read all labels
- Create label
- Assign label to message
Instructions:
Label Matching:
Analyze the email's subject, sender, recipient, keywords, and content. Compare with existing Gmail labels to find the most relevant match. Label Assignment:
Assign the email to the most appropriate existing label.` Remove the inbox label if the email is of less importance (like ads, promotions, aka "Reclame"), keep normal and important emails in the inbox. If no suitable label exists, create a new label based on the existing labels. Try reusing existing labels as much as possible. Always create a label as a sublabel, if no label applies, if the main label already exists, create the new label under the existing label, if no main label exists, create the label AI and create the new label under this label. Label Creation:
Ensure new labels align with the structure of existing ones, including capitalization, delimiters, and prefixes. Examples:
If the email subject is "Project Alpha Update," assign to [Project Alpha] if it exists. For "New Vendor Inquiry," create "Vendor Inquiry" if no relevant label exists. Outcome: Emails are consistently categorized under the appropriate or newly created labels, maintaining Gmail's organizational structure.
Gmail API
Gmail API
- Add credentials
OpenAI
OpenAI
- Add credentials
Gmail labelling agent
Gmail labelling agent
Purpose and structure
This folder contains the Gmail labelling agent workflow. Its executable nodes use agent, gmailTool, gmailTrigger, lmChatOpenAi, memoryBufferWindow, wait. 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/Stickynote/1353_Stickynote_Gmail_Send_Triggered.json MIT; preserve source notices.