Use this powerful n8n workflow to automatically categorize and label incoming Gmail messages using OpenAI's GPT-4. Improve productivity with smart, AI-driven email sorting.
Download this n8n workflow template and start using it instantly.
Business Owners and Executives overwhelmed by email volume.
Sales and Support Teams needing immediate categorization of inquiries (e.g., Quotation vs. Inquiry).
IT Professionals looking for advanced, AI-driven n8n templates for inbox management.
Anyone seeking to leverage an n8n node setup for sophisticated data classification.
Manually sorting and labeling high volumes of emails is a tedious and error-prone process. This automated solution transforms inbox management by implementing an intelligent n8n workflow that relies on cutting-edge AI.
This specific n8n template automatically listens for new messages in Gmail. Once an email arrives, it is processed by GPT-4, which analyzes the content and assigns categories like 'Quotation,' 'Project progress,' or 'Inquiry.' By replacing manual effort with this powerful n8n automation, users ensure consistent, immediate categorization, drastically improving response times and organizational efficiency. It’s a perfect example of how the n8n node ecosystem can handle complex linguistic tasks.
The entire process begins with a dedicated n8n trigger listening for new emails.
Assign labels for message) uses a defined system prompt to categorize the email content and return the chosen labels (e.g., Inquiry) in a strict JSON format.Set label values n8n node extracts the array of assigned label names.Merge n8n node combines the AI-assigned label names with the actual Gmail label IDs, finding the corresponding ID for each name.Aggregate n8n node collects all required IDs into a single array, which is then used by the final Gmail n8n node (Add labels to message) to update the original email with all the newly assigned, AI-derived labels. This demonstrates a seamless, end-to-end n8n workflow.To deploy this comprehensive n8n workflow, follow these setup steps:
Assign labels for message n8n node and the schema in the JSON Parser n8n node. If you change label names or categories in Gmail, you must update them in both these n8n node settings to maintain synchronization. Gmail trigger (n8n trigger):
Function: Starts the n8n workflow whenever a new email is received in the configured Gmail account.
Key Configuration: Simple polling mode, configured to check every minute.
Get message content (Gmail n8n node):
Function: Retrieves the full textual content of the message initiated by the n8n trigger, necessary for AI analysis.
Key Configuration: Uses the message ID from the preceding n8n node: ={{ $json.id }}.
OpenAI GPT-4 Based (OpenAI n8n node):
Function: Provides the language model (GPT-4) used for sophisticated content analysis.
Key Configuration: Model set to gpt-4-turbo-preview with response format set to jsonobject and temperature 0 (deterministic results).
Assign labels for message (Langchain n8n node):
Function: Sends the email text and a detailed instruction prompt to GPT-4 to categorize the content based on predefined labels.
Key Configuration: The system prompt strictly defines the four categories and requires JSON output.
JSON Parser (Langchain n8n node):
Function: Ensures the output from the AI is a valid JSON object matching the defined schema, specifically extracting the list of assigned labels.
Key Configuration: Uses a manual JSON schema specifying the possible labels array values.
Get all labels (Gmail n8n node):
Function: Fetches a complete list of all Gmail labels and their corresponding unique IDs, essential for the final labeling action.
Key Configuration: Resource set to label, operation set to getAll.
Merge corresponding labels (Merge n8n node):
Function: Matches the plain text label names provided by the AI with the corresponding label IDs retrieved from Gmail.
Key Configuration: Merge mode is combine, merging by field matching name and labels.
Add labels to message (Gmail n8n node):
Function: The final action in this n8n workflow, applying the collected label IDs to the original message, completing the automation.
Key Configuration: Uses aggregated labelids and the original message ID.
Use this efficient n8n workflow to automatically download Gmail invoice PDFs, upload them to Google Drive, and log key transaction data to Google Sheets. This n8n workflow simplifies financial record-keeping.

Use this robust n8n workflow to schedule hourly backups from an FTP server directly to Google Drive. Perfect for data archival and reliable cloud storage synchronization.

Deploy this powerful n8n workflow template to instantly log expenses sent via Telegram into Google Sheets, using an n8n AI Agent for categorization and currency conversion.

Use this secure n8n workflow template to manage Google Cloud Run authentication. It automatically checks token expiration with a 5-minute buffer and refreshes the JWT ID token only when necessary.








































