Templates / Real-time IoT anomaly detection with MQTT, GPT-4o-mini AI, and multi-channel alerts

Real-time IoT anomaly detection with MQTT, GPT-4o-mini AI, and multi-channel alerts

Ready for 3.0

by Cheng Siong Chin ✓ · 422 views · created 2025-11-12 · Engineering, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 17 nodes and runs on MQTT events (plus 1 other trigger). Along the way it connects MQTT, Postgres, OpenAI Chat Model and Slack.

How it runs

Trigger: On MQTT events (plus 1 other trigger).

  1. Workflow Configuration (Edit Fields (Set)): sets 5 fields: anomalyThreshold, dashboardApiUrl, slackChannel…
  2. Fetch Historical Data for Retraining (Postgres): run a query
  3. Edge Preprocessing & Validation (Code): runs custom JavaScript code
  4. Retrain ML Model via API (HTTP Request): calls an HTTP API (POST)
  5. Normalize Sensor Data (Edit Fields (Set)): sets 7 fields: sensor_id, timestamp, value…
  6. Store Raw Data in Time-Series DB (Postgres): uses Postgres
  7. Aggregate: combines items into one
  8. Statistical Anomaly Detection (Code): runs custom JavaScript code
  9. AI Anomaly Detection Agent (AI Agent): runs an AI agent, with model: OpenAI Chat Model
  10. Check for Anomalies (If): checks a condition and branches into true / false

…plus 4 more steps. See the full node list below.

Services it uses

MQTTPostgresOpenAI Chat ModelSlack

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (12)

From the author

How It Works MQTT ingests real-time sensor data from connected devices. The workflow normalizes the values and trains or retrains machine learning models on a defined schedule. An AI agent detects anomalies, validates the results for accuracy, and ensures…

Excerpt from Cheng Siong Chin's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.