Triage inbound email with IMAP, custom AI HTTP APIs and SMTP

Go to Workflow
0 views
Built by Ck Lu Ck Lu
Created on September 19, 2026

Description

Quick overview
This workflow triages inbound email by fetching messages via IMAP (or receiving them via webhook), sending the content to external AI HTTP endpoints to classify and draft a reply, then either routes the draft for human approval or replies via SMTP and logs the outcome.

How it works
Runs on a schedule to poll an IMAP inbox for unseen messages, or receives inbound messages as JSON via a webhook.
Normalizes each message into a consistent structure (message ID, sender, subject, body, and received time).
Sends the normalized content to a classification API endpoint that returns strict JSON labels (for example category and confidence).
Sends the message and classification results to a drafting API endpoint to generate a reply draft in your chosen tone.
Applies routing rules to decide whether the draft can be auto-sent or must go to a human review queue.
If auto-sending is enabled, replies to the original sender via SMTP in the same email thread and logs the sent message to a database endpoint.
If human review is required, creates a queue item, notifies an approver via a webhook (for example Slack or email), and logs the pending-review status to a database endpoint.

Setup
Create and select an IMAP credential for reading mail and an SMTP credential for sending replies, and set the from address used for SMTP.
Choose a single entry point (scheduled IMAP polling or the inbound webhook) and disable the other to avoid processing the same message twice.
Provide working URLs (and any required authentication headers) for the classification API, drafting API, logging database write API, and the approver notification webhook.
Update the approval policy (for example keep auto-send off initially and define confidence/category rules) and, if using webhook push mode, copy the webhook URL into your source system that forwards inbound messages.

Nodes Used (3)

Code
n8n-nodes-base.code
HTTP Request
n8n-nodes-base.httpRequest
Send Email
n8n-nodes-base.emailSend