See llms.txt for all machine-readable content.

Back to Templates

Triage shared inbox emails with OpenAI and human-in-the-loop approval

Quick overview

This workflow monitors a shared IMAP inbox, uses OpenAI to classify each incoming email and draft a short reply, then emails the draft to an approver for one-click approval before sending the response back to the original sender.

How it works

  1. Triggers when a new email arrives in a shared inbox via IMAP and marks the message as read.
  2. Prepares the email details (sender, subject, message text) and loads configuration like company name and approval addresses.
  3. Uses OpenAI to classify the email into categories such as quote request, appointment, complaint, invoice question, general, or spam.
  4. Stops processing for spam messages so no reply is drafted or sent.
  5. Uses OpenAI to draft a short reply in the sender’s language based on the classified case and the original message.
  6. Sends the proposed reply to an approver by email with Approve/Decline buttons and waits up to two days for a decision.
  7. If approved, sends the reply to the original sender from the configured mailbox; if declined, stops so the email can be handled manually.

Setup

  1. Add IMAP credentials for the shared inbox in the email reading step.
  2. Add an OpenAI API credential for both the classification and reply generation model steps (or swap in another compatible chat model).
  3. Add SMTP/email-sending credentials for sending the approval request and the final reply.
  4. Update the configuration values for company name, the “from” address used to send emails, and the approver’s email address.

Requirements

  • IMAP and SMTP access to a shared mailbox (e.g. info@)
  • OpenAI API key, or any other chat model supported by n8n (for example a local Ollama model)

Customization

  • Rename, add or remove categories in the Classify email node and connect new outputs to a matching Case node
  • Adjust tone, length and rules of the replies in the Draft reply prompt
  • Change the approval timeout (default two days) in Ask for approval

Additional info

If the AI cannot classify an email, it is routed to the General case, so no message is lost. Approval links opened by link-preview bots are ignored by n8n; only a real click counts. Tested with n8n 2.42.