Platform Notes · Workflow

From IoT Alert to ERP Work Order: Closing the Loop with n8n and ERPNext

The gap between "the dashboard showed the alert" and "someone typed it into the ERP three hours later" is where most industrial IoT value quietly leaks away. Here is how the Barquecon platform closes it — automatically, with no re-keying.

By Barquecon Technologies Published August 6, 2026 9 min read

A machine-vibration alert that only ever reaches a dashboard is a monitoring project, not a maintenance system. The moment that actually changes outcomes is when the alert becomes a work order — assigned, tracked, closed out — without a supervisor re-keying it by hand from a screen into the ERP. That hop, alert to work order, is the flagship flow this note describes.

How the flow works

A customer’s existing shop-floor devices — PLCs, meters, VFDs — feed the Barquecon platform through @bqt/modbus-adapter, the connectivity adapter described in our companion note on Modbus integration. When a rule fires on that telemetry, the platform raises an alert and, via the createTicket action, hands it to n8n, which creates a Work Order or Issue in ERPNext, the recommended open-source ERP. This is the "IoT alert → ERP work order" flow that every one of our industry blueprints references.

Built-in dry-run mode. The n8n flow includes a DRY_RUN mode that logs the exact ERPNext payload it would post, without creating a live record — so you can validate the field mapping against your own ERPNext instance before go-live.

The architecture, device to work order

  1. PLC / meter / VFD registers, read over Modbus TCP or RTU (see our companion Modbus note for how we wire the transport into your rollout).
  2. @bqt/modbus-adapter decodes the raw registers into a TelemetryEvent: { deviceId, ts, metrics, event? }.
  3. Platform ingestion hands the event to the Rules engine, which evaluates a RuleDefinition (metric, operator, threshold, sustained duration).
  4. A rule that fires with a createTicket action (target: "external") is handed to the Notification/Workflow orchestrator.
  5. The orchestrator HTTP-POSTs a small, stable JSON envelope to an n8n webhook.
  6. The n8n flow maps the envelope to an ERPNext doctype. In DRY_RUN, it logs the payload and returns 200. In live mode, it POSTs to /api/resource/Work Order (or Issue) and gets back a work-order ID.

Nothing in this bundle changes the underlying telemetry contract — the alert-to-ERP hop reuses the platform’s existing createTicket rule action, so no contract edit was needed to wire it.

The trigger payload

The platform posts this envelope to the n8n webhook when a createTicket action fires. Every field derives directly from the telemetry contract:

{ "tenantId": "tenant-acme", "deviceId": "dev-line2-cnc-3", "ts": 1770000000000, "rule": { "ruleId": "oee-availability-low", "metric": "availability_pct", "op": "<", "value": 60 }, "event": { "type": "availability_breach", "severity": "critical", "message": "Line 2 CNC-3 availability 54% for 15m" }, "metrics": { "availability_pct": 54, "spindle_rpm": 0, "motor_run": 0 }, "idempotencyKey": "tenant-acme:dev-line2-cnc-3:oee-availability-low:1770000000000" }

The idempotencyKey is {tenantId}:{deviceId}:{ruleId}:{alertWindowStartMs} — stable for the life of one breach, so retried or redelivered alerts do not create duplicate work orders.

Field mapping, envelope to ERPNext

ERPNext field (Issue)Source
subjectevent.type + deviceId
descriptionevent.message + metrics table
priorityevent.severity — critical→Urgent, warning→High, info→Medium
raised_byfixed service account, e.g. iot-bot@<tenant>
custom_device_iddeviceId
custom_rule_idrule.ruleId
custom_idempotency_keyidempotencyKey — unique, the dedupe anchor
custom_assetresolved from deviceId via ERPNext Asset link, if provisioned

Idempotency: no duplicate work orders

The platform may redeliver an alert at least once. Before creating a document, the flow queries ERPNext for an existing Issue with a matching custom_idempotency_key. If one is found, it returns the existing name and does nothing — idempotent success. If not found, it creates a new record. In DRY_RUN the lookup step is skipped and the payload is logged with the key, so the dedupe contract stays visible for testing.

Validating the mapping against your own n8n instance

  1. Import the flow definition into your n8n instance, or pilot it on ours — we run n8n self-hosted, already live and carrying other production workflows.
  2. Leave the DRY_RUN flag at true on the workflow.
  3. POST the sample envelope above to the webhook URL.
  4. The flow returns { ok: true, dryRun: true, wouldCreate: { doctype, subject, priority, ... } } and logs the full ERPNext payload it would send — proving the mapping before you connect a live ERP.

What's built, and what we set up for your site

The payload envelope, the field mapping, and the idempotency design are fixed and documented — that's the contract every deployment uses, and n8n runs self-hosted today, already carrying other production workflows. Connecting your specific ERPNext instance — API credentials, Asset linkage, custom fields — and turning on live device telemetry from your PLCs and meters are the two pieces our engineers build for your rollout, using the same Modbus connectivity covered in our companion note.

PieceStatus
Envelope + field mapping specificationBuilt in
n8n flow with dry-run modeReady to run
Self-hosted n8n instanceLive in production
Your ERPNext instance, connectedWe build this for your rollout
Live device telemetry feeding the pipelineWe wire this during onboarding

The seam — the exact payload shape, the field mapping, the idempotency design — is settled and testable today. Standing it up against your ERPNext instance and your device fleet is an integration project our team runs against that known contract, not an open design question.

Want to see the rule that starts this flow?

The factory demo shows the predictive-maintenance story this workflow is built to close the loop on.

Book a pilot Run the live demo

Let's Work Together

Contact Us and We'll Help You

Whether you have a question, an idea, or a project in mind, our team is ready to assist you every step of the way.