Back to Templates

Automatically Label Gmail Emails with GPT-5 Classification

Created by

Created by: Abideen Bello || bideen

Abideen Bello

Last update

Last update 15 days ago

Share


How it works

This workflow automatically monitors your Gmail inbox and uses OpenAI's GPT model to intelligently classify incoming emails into four key categories:

  • High Priority - Urgent emails requiring immediate attention from executives, clients, or stakeholders
  • Promotion - Marketing emails, sales offers, product launches, and event invitations
  • Finance/Billing - Invoices, receipts, payment notifications, and financial records
  • Customer Support - Help requests, troubleshooting queries, and service-related issues

Once classified, emails are automatically labeled in Gmail using the appropriate tags, making it easy to filter, search, and prioritize your communications.

How to set up

Requirements

  • Gmail account with OAuth2 access enabled
  • OpenAI API key with GPT model access
  • Custom Gmail labels created for each category

Step-by-step setup

  1. Create Gmail Labels
  • In Gmail, create these labels: "High Priority", "Promotion", "Finance/Billing", "Customer Support"
  • Note the label IDs (you'll need to replace the hardcoded ones in the workflow)
  1. Configure Credentials
  • Add your Gmail OAuth2 credentials in n8n
  • Add your OpenAI API credentials
  1. Update Label IDs
  • Replace the hardcoded label IDs in each Gmail node with your actual label IDs
  • You can find label IDs by testing the Gmail node or using Gmail API
  1. Adjust Classification Rules
  • Review the Text Classifier categories and modify descriptions to match your specific needs
  • Add or remove categories as required
  1. Set Polling Frequency
  • The workflow is set to check every minute - adjust based on your email volume