Skip to main content

Accelerate Your IIoT Development with AI

You’ve installed Coreflux and deployed your first Action. Now what if you could describe your next feature in plain English and have an AI assistant write the LoT (Language of Things) code for you — correctly, using verified syntax, following best practices? That’s exactly what Coreflux’s AI integration enables. By connecting your AI assistant to the Coreflux MCP (Model Context Protocol), you give it real-time access to the official documentation. The result: you describe your goal, and the AI produces production-ready LoT code — Actions, Routes, Models, and more — without you memorizing a single keyword.
Like hiring a LoT specialist who never sleeps. You explain what your factory floor needs — “alert me when temperature spikes” — and the specialist drafts the code, wires the database, and writes the documentation.

When to Use This

  • You want to build IIoT features faster by describing them in natural language
  • You’re new to LoT syntax and want correct code without a learning curve
  • You need to connect PLCs, databases, and alerts and want AI to handle the wiring
  • You want AI to document your system as you build it

Step 1: Installation & Prerequisites

Before using AI with Coreflux, ensure the core environment is running.
1

Install the Coreflux Broker

Follow the Installation Guide for your platform (Docker, Windows, Linux, or Raspberry Pi). Verify the broker is running by connecting with MQTT Explorer.
2

Verify Your Setup

Connect to the broker and subscribe to $SYS/#. If you see system topics, the broker is ready.
If you haven’t completed the Getting Started guide yet, do that first. It takes under 15 minutes and confirms your environment is working.

Step 2: Setup AI (MCP & Agents)

Coreflux uses the Model Context Protocol (MCP) to give your AI assistant real-time access to the official documentation. This means the AI doesn’t guess at LoT syntax — it looks it up. Combined with an AGENTS.md file that defines your project’s conventions, your AI assistant becomes a LoT expert that follows your team’s rules.

Configure the MCP Connection

Add the Coreflux documentation MCP server to your AI client. Use Native to install from the contextual menu on any docs page, or Manual to add the server URL to a config file.
Open the Copy page menu (top right) on any Coreflux documentation page. From there you can copy the MCP URL, run the install command, or connect directly to VS Code or Cursor.
Documentation page contextual menu showing Copy MCP Server, Copy MCP install command, Connect to Cursor, and Connect to VS Code

Contextual menu with MCP install options

1

Connect from the menu

Select Connect to VS Code from the contextual menu.
2

Install the server

Click Install or Install in Workspace on the MCP server page.
VS Code MCP Server tab for Coreflux Documentation with Install buttons and server URL configuration

VS Code MCP server install page

3

Enable in Copilot

Reload VS Code if needed, open Copilot Chat in Agent mode, and enable the Coreflux tools.
For full setup details, editor-specific steps, and verification, see the MCP Configuration Guide.

Set Up AGENTS.md (Project Rules)

An AGENTS.md file in your project root tells your AI assistant how to write LoT code — naming conventions, patterns, and what to avoid. Without it, the AI may use inconsistent styles or invent syntax. Create an AGENTS.md file in your project root with your project’s conventions. The Best Practices & AGENTS.md page provides a complete starter template covering:
  • Naming rules — PascalCase for entities, snake_case for variables
  • Topic hierarchysensors/, processed/, alerts/ namespaces
  • Code standards — Type casting, state management, modular Actions
  • Boundaries — What the AI should always do, ask about, and never do
For a faster start, clone the Coreflux AI Starter repo — it includes ready-to-use templates and pre-built MCP configs for every editor.
Once both the MCP and AGENTS.md are configured, your AI assistant has real-time documentation access and your project’s coding standards. You’re ready to build.

Step 3: Create LoT with AI

With your AI assistant connected via MCP, you can use natural language to perform complex IIoT tasks. The following examples demonstrate the full workflow — from prompt to deployable code.

A. Generate a LoT Action from Scratch

The most common starting point: you describe a behavior, and the AI writes the Action. The Prompt:
AI-Generated Output: The AI consults the Coreflux MCP documentation and produces verified LoT syntax:
Why this works: Deploy and Test:
1

Deploy the Action

Paste the code into a LoT Notebook cell (.lotnb file) and run it, or publish to $SYS/Coreflux/Command with the -addAction prefix.
2

Send a Test Message

Publish to factory/sensor/temp:
3

Verify the Alert

Subscribe to alerts/hvac. You should see:

B. PLC Integration & Automated Routing

A real-world scenario: you have a Siemens S7 PLC on the factory floor, and you want its data flowing into a PostgreSQL database. This requires two Routes — one to read from the PLC, and one to store in the database. Topics are the bridge between them. The Prompt:
AI Logic:
  1. Analyze — The AI identifies the source (Siemens S7 PLC), the data bridge (MQTT topics), and the destination (PostgreSQL)
  2. Design — It creates two Routes: an industrial Route for the PLC, and a data storage Route for the database
  3. Generate — Using the MCP to verify syntax, it produces:
Route 1 — Read from the PLC:
This Route reads PLC data and publishes it to MQTT topics every 500ms. Route 2 — Store in PostgreSQL:
The AI generates a database Route that subscribes to the MQTT topics published by the PLC Route and inserts every reading into a sensor_readings table — complete with SQL templates, connection config, and event triggers, without you writing a single line of SQL manually. The Data Flow:
The PLC Route and PostgreSQL Route are independent — they communicate through MQTT topics. This decoupled architecture means you can add more consumers (alerts, dashboards, other databases) without modifying the PLC Route. For a step-by-step walkthrough of building a database Route from scratch, see the Developing with LoT Using AI guide.

C. Modify Existing Code & Generate Documentation

AI excels at iterating on existing code and producing documentation alongside it. The Prompt:
AI-Updated Code: The AI modifies the existing Action and adds the logging line:
AI-Generated Documentation: The AI also produces a markdown summary you can add directly to your project’s LoT Notebook (LoTNB):
This is the complete cycle: build → modify → document — all driven by natural language prompts.

Best Practices

To get the most out of AI-assisted LoT development, keep these principles in mind:
  • Always verify the MCP connection before starting a session. Without it, the AI may generate plausible-looking but incorrect LoT syntax
  • Be specific in your prompts — include topic names, payload formats, thresholds, and hardware details. The more context you provide, the more accurate the output
  • Build incrementally — deploy and test one Action, Route, or Model at a time before moving to the next
For detailed prompt templates, see Prompt Patterns That Work. For naming conventions and a project rules template, see Best Practices & AGENTS.md.
If your AI assistant generates LoT code without consulting the MCP, the syntax may be invented. Always verify that the MCP tools are active before trusting the output.

Next Steps

Creating Agents in Coreflux

Deploy AI agents on the broker — chat, automation, and multi-agent teams defined in LoT.

Developing with LoT Using AI

Deep-dive into the full AI-assisted workflow — planning, building, verifying, and scaling your IIoT system.

Best Practices & AGENTS.md

Set up naming conventions, code patterns, and a project rules template to keep your AI assistant consistent.
Last modified on May 22, 2026