n8n template · AI Inbox Pack
Detect urgent emails with an AI score in n8n
This workflow exposes a scoring webhook: send it any email (subject, sender, body) and an LLM assigns an urgency score from 1 to 5, justified and paired with a suggested action. Above the threshold, Slack rings; below it, the email quietly waits for the daily digest.
- Email reçu (Webhook)triggerWebhook
- Extraire les champsSet (fields)
- Scorer l'urgenceLLM chain
- Urgent ?IF (condition)
- Alerte SlackSlack
- Mettre en file pour le digestSupabase
- Répondre au webhookWebhook response
Attached AI sub-nodes
- Modèle OpenAIOpenAI model
- Score structuréStructured output
$ n8n import:workflow --input=priorisation-urgence-emails.json ✔ Import successful — 9 nodes, valid connections
The problem it solves
The real cost of email isn't reading it — it's being interrupted by messages that didn't deserve it. Without prioritization, every notification is equal: the critical customer outage and the sales follow-up arrive with the same ding.
Give a model an explicit urgency rubric (blocking incident = 5, prospecting = 1) and you get reproducible, contextual triage. The webhook architecture makes the scoring reusable: shared inbox, contact form, CRM — anything that can send a POST can ask for a score.
How the workflow works, node by node
Node names are in French, exactly as they appear in the imported workflow — the logic is language-agnostic.
- 01
Email reçu (Webhook)
WebhookHTTP POST entry point (path flowkit-email-score): it receives JSON with subject, from and body. The responseNode mode lets the workflow return the score to the caller.
- 02
Extraire les champs
Set (fields)Normalizes the payload and truncates the body to 4,000 characters: clean input for the LLM, bounded token cost.
- 03
Scorer l'urgence
LLM chainApplies a detailed urgency rubric (from 1, newsletter, to 5, blocking incident), with instructions not to be fooled by marketing 'URGENT' subject lines.
- 04
Modèle OpenAI
OpenAI modelgpt-4o-mini as an ai_languageModel sub-node: fast and cheap, ideal for scoring called on every email.
- 05
Score structuré
Structured outputGuarantees strict JSON output: integer score 1–5, one-sentence reason, suggested action starting with a verb. The next IF compares numbers, not text.
- 06
Urgent ?
IF (condition)Compares the score to the threshold (4 by default). The only setting to touch to make the system more or less sensitive.
- 07
Alerte Slack
Slack'True' branch: immediate alert with score, reason and suggested action — your team knows what to do before even opening the email.
- 08
Mettre en file pour le digest
Supabase'False' branch: inserts the scored email into the emails_queue table with pending status, where the daily digest workflow will pick it up.
- 09
Répondre au webhook
Webhook responseReturns the score to the caller as JSON: the system that sent the POST can react too (label, CRM routing…).
What you need to run it
- n8n ≥ 1.60 with the LangChain nodes
- An OpenAI API key
- A Slack bot (chat:write scope) for alerts
- A Supabase project with the emails_queue table (SQL provided in the pack guide)
- A system able to send emails to the webhook (forwarding rule, script, another n8n workflow)
Customization ideas
- Adapt the rubric to your business: 'email from a client under contract = 4 minimum' is a one-line prompt change
- Replace Slack with Teams, Telegram or SMS depending on your on-call channel
- Add a 'department' field to the structured schema to route to the right team
FAQ
Frequently asked questions
How do I import this template into n8n?
Import priorisation-urgence-emails.json via 'Import from File', attach your OpenAI, Slack and Supabase credentials, activate the workflow, then copy the production webhook URL shown on the entry node.
How do I send incoming emails to this webhook?
Three common options: the IMAP workflow from the same pack (it can call this webhook), a forwarding rule to a parsing service, or a POST from your backend. The webhook only expects three JSON fields: subject, from, body.
Can the model get the score wrong?
Occasionally, at the margins — that's why the output includes a justification. In practice, with an explicit rubric, discrepancies cluster between adjacent scores (3 vs 4): adjust the threshold or the rubric rather than chasing a perfect score.