HASON Marcel AI engineering

AI experiment

n8n automation with AI approval

n8n Ollama llama3 PHP webhook

Automation is great, but letting AI send e-mails unsupervised is a recipe for disaster. So I built an n8n workflow around the human in the loop principle: every incoming e-mail passes through a local llama that classifies it (inquiry / invoice / spam) and drafts a reply. The draft lands in my Telegram with Approve / Edit / Discard buttons.

Sending is handled by a small PHP webhook – after approval n8n posts JSON to it and the PHP script sends the final version via PHPMailer. In the first month 214 e-mails went through the workflow and I approved 87% of the drafts without any edits.

[n8n] IMAP trigger -> new e-mail
[n8n] HTTP request -> http://localhost:11434/api/generate
      model: llama3, prompt: classify + draft a reply
[n8n] Telegram -> "Client inquiry, draft reply: ..."
      [ Approve ] [ Edit ] [ Discard ]
[php] POST /webhook/send-mail.php
  > 200 OK, e-mail sent, logged to DB