Gmail triage labels via OpenRouter

Applies one of six AI labels to unread Gmail. This n8n template polls Gmail every minute for up to 50 unread inbox messages, normalises sender, subject and body, and sends them to a Gemini model through OpenRouter. The model returns JSON with category, priority, language, confidence and a short summary. The six categories are New lead, Existing client, Pricing, Invoice, Vendor pitch and Spam. The workflow validates the JSON, resolves the label ID, applies the label and removes UNREAD. It never replies to mail, and a run fails if the model output is not valid JSON.

n8nRead on 2026-11-166 steps

Steps

  1. Trigger: Polls Gmail every minute for up to 50 unread messagesGmail
  2. Extracts and normalizes safe fields from each email
  3. Sends the normalized email content to OpenRouter (Google Gemini)OpenRouter
  4. Validates the AI response and maps the category
  5. Loads your existing Gmail labels and resolves the required labelGmail
  6. Output: Applies the resolved Gmail label to the messageGmail

Limits

  • If the AI returns invalid JSON the run fails on purpose.
  • Label names are case-sensitive and must match the six listed in Setup exactly.

What it does well

  • The workflow never sends or replies to email.

Before you import

Create the six Gmail labels under the AI Triage/ prefix, with names that match the setup list exactly; label names are case-sensitive.

Similar templates