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.

0
Downloads
0
Views
8.18
Quality Score
beginner
Complexity
Author:Taku (AI Jidoka Lab)(View Original →)
Created:7/25/2026
Updated:7/25/2026

🔒 Please log in to import templates to n8n and favorite templates

Workflow Visualization

Loading...

Preparing workflow renderer

Comments (0)

Login to post comments