# AI shared inbox triage n8n template

> An importable n8n workflow that polls a shared Gmail inbox every minute, drops auto-replies, bounces and internal mail in code, has Claude pick one of seven buckets as strict JSON, and applies the matching Gmail label. Sales inquiries become HubSpot contacts with a Slack alert. You need n8n, Gmail, an Anthropic API key, a HubSpot private app and Slack.

- Platform: n8n
- Download: https://www.lumeor.studio/templates/n8n/ai-email-inbox-triage.json
- Trigger: New Gmail message in the shared inbox, polled every minute
- Credentials needed: Gmail OAuth2, Anthropic API, HubSpot private app token, Slack
- Full guide: https://www.lumeor.studio/guides/ai-email-inbox-triage/
- Last updated: 2026-10-14

## What this workflow does

1. **New email in shared inbox** (Gmail Trigger) polls for inbox messages that do not yet carry `ai-triaged` or `ai-unsure`.
2. **Pre-filter** (Code) skips auto-replies, bulk mail, bounces and senders from your own domains before any model call, and trims quoted history so Claude reads only the newest message.
3. **Classify with Claude** (HTTP Request) calls the Anthropic Messages API with a strict JSON schema: one bucket, a confidence score, a reason, and contact name, company and phone when they appear.
4. **Parse and route** (Code) handles refusals, truncated answers and API errors, rejects unknown buckets, and marks anything under the confidence threshold as unsure.
5. **Confident?** (If) splits sorted mail from mail that needs a person.
6. **Apply bucket labels** (Gmail) adds the bucket label and `ai-triaged`.
7. **Sales inquiry?** (If) sends new leads to **Create HubSpot contact**, which creates or updates the contact by email, and **Notify sales** in Slack with a Gmail link.
8. **Label as unsure** and **Post inbox exception** handle everything else, so nothing is silently dropped.

## Before you import

- A current n8n version and access to the shared Gmail account through OAuth.
- An Anthropic API key. The template uses `claude-opus-5-5`; `claude-haiku-5-5` is cheaper for high-volume sorting.
- A HubSpot private app token with contact read and write scopes. Choose "Service Key" authentication on the HubSpot node.
- A Slack bot added to the sales and exceptions channels.

## Setup

1. Import the JSON and connect the Gmail, Anthropic, HubSpot and Slack credentials.
2. In Gmail, create one label per bucket plus `ai-triaged` and `ai-unsure`.
3. In **Parse and route**, replace each `REPLACE_WITH_LABEL_ID_...` value with the Gmail label ID (it looks like `Label_123`, not the label name).
4. In **Pre-filter**, replace `REPLACE_WITH_YOUR_DOMAIN.com` with your domains, and edit the bucket definitions to match how your team thinks about the inbox.
5. Replace `REPLACE_WITH_SLACK_SALES_CHANNEL_ID` and `REPLACE_WITH_SLACK_EXCEPTIONS_CHANNEL_ID`.
6. Tune `MIN_CONFIDENCE` (0.7 by default) after your first week of results.

## Test it

Send the shared inbox four emails from a personal address: a pricing question, a support request, a fake invoice and a vague one-liner. Run the workflow manually and check labels in Gmail. The pricing question should create a HubSpot contact and a Slack alert. The one-liner should land in `ai-unsure`. An out-of-office reply should never reach the model.

## Make it production-ready

- Run label-only for a week by disconnecting the HubSpot node, as the guide recommends, then turn actions on bucket by bucket.
- Add an n8n error workflow so Gmail or HubSpot failures alert someone.
- The Claude call retries three times. Check HubSpot's API limits for your plan if the inbox is busy.
- Add a forward step for the billing bucket to your AP address once labels prove reliable.
- Review the `ai-unsure` label daily. Repeated unsure messages usually mean a bucket definition needs rewriting.

Read the full guide on [AI shared inbox triage](/guides/ai-email-inbox-triage/) for bucket design and mailbox access, or [get help from Lumeor](/start/) with Outlook or a custom routing table.

---

Source: https://www.lumeor.studio/templates/ai-email-inbox-triage/
Published by Lumeor Studio, Newtown, PA. hello@lumeor.studio. Get a written scope: https://www.lumeor.studio/start/
