Label Gmail emails by priority with Groq Llama 3.3
Quick overview This workflow polls Gmail for new emails, sends the email text to Groq’s OpenAI-compatible chat completions API (Llama 3.3) to classify it, and then applies the matching Gmail label for Action Required, Promotions, or Other.
How it works Triggers when a new email is received in Gmail (polled every minute). Sends the email body/snippet to Groq’s chat completions endpoint (Llama 3.3 70B) and requests a JSON category classification. Parses the model’s JSON response and falls back to Other if parsing fails, while keeping the original Gmail message ID. If the category is Action Required, adds the configured Gmail label to the message. If the category is Promotions, adds the configured Gmail label; otherwise, adds the configured Other label.
Setup Create and select a Gmail OAuth2 credential for the trigger and all Gmail label actions. Add your Groq API key by replacing Bearer YOUR_GROQ_API_KEY in the Authorization header of the HTTP request. Create the three Gmail labels (Action Required, Promotions, Other) and select their label IDs/names in each corresponding Gmail “add labels” action.
Requirements A Gmail account (OAuth2 credential) and a free Groq API key from console.groq.com — no credit card required. Works on n8n Cloud or self-hosted.
Customization Edit the plain-English rules in the system prompt of the AI node to add categories or domain-specific rules (e.g. "emails from acme.com are always Action Required"). You can also swap Groq for OpenAI or any OpenAI-compatible endpoint by changing the URL, model and Authorization header.
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments