AI Email Triage System — Auto-classify, route & alert using Groq + Gmail + Google Sheets

:robot: What this workflow does

This workflow automatically triages every incoming email using AI. The moment a new email lands in Gmail, it gets classified by Groq’s ultra-fast llama-3.1-8b-instant model, routed to the right department, logged into a Google Sheet, and — if it’s urgent — fires an instant alert email. Zero manual sorting required.

Perfect for: small business owners, operations teams, or anyone drowning in a mixed inbox.


:sparkles: Features

  • AI classification — categorizes every email into: invoice, customer_complaint, job_application, general_inquiry, or spam

  • Department routing — automatically routes to Finance, Customer Service, HR, or Operations

  • Google Sheets log — every triaged email is appended to a central tracking sheet with date, sender, category, urgency, summary, and action needed

  • Department notifications — each department receives a formatted email alert with a one-line AI summary and action item

  • Urgent alert — high-priority emails trigger a separate instant alert to a designated recipient

  • Spam ignored — spam and unclassified emails are silently dropped, no noise


:world_map: How it works — node by node

1. Gmail Trigger Polls your Gmail inbox every minute for new emails. You can change the polling interval in the node settings.

2. Groq AI Triage (HTTP Request) Sends the email subject, sender, and body to Groq’s llama-3.1-8b-instant model via their OpenAI-compatible API. The system prompt instructs the model to respond with a strict JSON object — no markdown, no prose. Temperature is set to 0.1 to ensure consistent, deterministic classification.

The AI returns:

json

{
  "category": "invoice",
  "department": "finance",
  "urgency": "high",
  "summary": "Vendor invoice #1234 for $5,000 due Friday",
  "sender_name": "John Smith",
  "action_needed": "Process payment before due date"
}

3. Parse AI Response (Code node) Parses the AI’s JSON response and merges it with the original Gmail data (subject, sender, date). Handles edge cases where the model wraps the output in markdown code fences. Also catches parse errors gracefully — if the AI response can’t be parsed, the email is flagged for manual review.

4. Route by Department (Switch) Routes the parsed data to one of four branches based on the department field. Emails with department: none (spam, unrecognized) are dropped silently via the fallback setting.

5. Notify [Department] (Gmail Send — ×4) Each department branch sends a formatted HTML email to that team’s inbox with the AI summary, urgency level, and action item. Subject line is prefixed with the department name and urgency for easy inbox filtering.

6. Log to Triage Sheet (Google Sheets) All matched emails (regardless of department) are appended to a central Google Sheet with these columns: Date, From, Subject, Category, Department, Urgency, Summary, Action Needed.

7. High Urgency? (IF node) Checks if urgency = high. Runs after the sheet log.

8. Send Urgent Alert (Gmail Send) If urgency is high, fires an additional alert email to a designated recipient (e.g. a manager or shared ops inbox) with the full context. Non-urgent emails pass to a no-op node.


:toolbox: Prerequisites

Before importing, make sure you have:

Requirement Details
Groq API key Free at console.groq.com — the llama-3.1-8b-instant model is free tier
Gmail account The account whose inbox will be monitored
Google Sheet Create a sheet with columns: Date, From, Subject, Category, Department, Urgency, Summary, Action Needed
n8n credentials set up Gmail OAuth2, Groq (Header Auth), Google Sheets OAuth2

:gear: Setup — step by step

Step 1 — Import the workflow In n8n: top-right menu → Import from file → select the JSON file

Step 2 — Connect the Groq credential

  1. Go to Credentials in n8n

  2. Create a new Header Auth credential

  3. Name: Groq API (or anything you like)

  4. Header Name: Authorization

  5. Header Value: Bearer YOUR_GROQ_API_KEY

  6. Open the Groq AI Triage node and select this credential

Step 3 — Connect Gmail

  1. Open the Gmail Trigger node → connect your Gmail OAuth2 account

  2. Repeat for each Notify node and the Send Urgent Alert node (all use the same Gmail account)

Step 4 — Connect Google Sheets

  1. Open Log to Triage Sheet → connect your Google Sheets OAuth2 account

  2. Make sure the spreadsheet ID and sheet name match your sheet (update if needed)

Step 5 — Fill in email addresses Open each of these nodes and set the To field to the relevant inbox:

  • Notify Finance → e.g. finance@yourcompany.com

  • Notify Customer Service → e.g. support@yourcompany.com

  • Notify HR → e.g. hr@yourcompany.com

  • Notify Operations → e.g. ops@yourcompany.com

  • Send Urgent Alert → e.g. your personal email or a manager’s inbox

Step 6 — Activate Toggle the workflow to Active. It will start polling Gmail every minute.

:paperclip: Workflow JSON: email-triage-ai.json · GitHubWorkflow Json

2 Likes