What this workflow does
- New email in shared inbox (Gmail Trigger) polls for inbox messages that do not yet carry
ai-triagedorai-unsure. - 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.
- 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.
- Parse and route (Code) handles refusals, truncated answers and API errors, rejects unknown buckets, and marks anything under the confidence threshold as unsure.
- Confident? (If) splits sorted mail from mail that needs a person.
- Apply bucket labels (Gmail) adds the bucket label and
ai-triaged. - 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.
- 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-5is 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
- Import the JSON and connect the Gmail, Anthropic, HubSpot and Slack credentials.
- In Gmail, create one label per bucket plus
ai-triagedandai-unsure. - In Parse and route, replace each
REPLACE_WITH_LABEL_ID_...value with the Gmail label ID (it looks likeLabel_123, not the label name). - In Pre-filter, replace
REPLACE_WITH_YOUR_DOMAIN.comwith your domains, and edit the bucket definitions to match how your team thinks about the inbox. - Replace
REPLACE_WITH_SLACK_SALES_CHANNEL_IDandREPLACE_WITH_SLACK_EXCEPTIONS_CHANNEL_ID. - 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-unsurelabel daily. Repeated unsure messages usually mean a bucket definition needs rewriting.
Read the full guide on AI shared inbox triage for bucket design and mailbox access, or get help from Lumeor with Outlook or a custom routing table.