> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting Started

> Go from zero to your first working LoT Action in under 15 minutes.

<Frame caption="Coreflux HUB overview — start here">
  <img src="https://mintcdn.com/coreflux/W9CJ-kgVY3a3sCeL/images/hub-overview-start.png?fit=max&auto=format&n=W9CJ-kgVY3a3sCeL&q=85&s=03fbe6e0a1dff699bc4f034f7701cd7d" alt="Coreflux HUB overview screen with a 'Start here' arrow pointing to the first navigation icon in the bottom toolbar" width="1024" height="639" data-path="images/hub-overview-start.png" />
</Frame>

## Why This Guide?

This is the fastest way to validate your Coreflux setup: in under 15 minutes you'll have a live LoT (Language of Things) Action running inside your broker—proof that your installation works and logic executes at the edge. New to Coreflux? Start with the [Overview](../index).

<Tip>
  **Like installing an app on your router instead of your phone.** LoT Actions run directly inside the broker -- your logic executes at the edge without an external script or server.
</Tip>

## Prerequisites

Before you begin, ensure you have:

* **A running Coreflux Broker** — See the [Installation Guide](/v2.0/quick-start/installation) if you haven't set one up yet
* **VS Code** with the LoT Notebooks extension *or* access to the [Coreflux HUB](/v2.0/coreflux-hub/overview) in your browser — see the [VS Code Setup Guide](/v2.0/quick-start/vscode) for the extension
* **Basic MQTT knowledge** — Understanding of topics, publish/subscribe patterns

***

Ready? Here's what you'll build and deploy.

## Your First LoT Action in 15 Minutes

> **Concept Refresher**: You are about to write an action that lives and runs **inside** the broker, not on your laptop.

Let's create a **simulated temperature sensor** that publishes a temperature reading every 5 seconds. You'll see data on a topic as soon as you deploy—no external input required. This keeps the whole guide in a single "temperature monitoring" flow.

### Understanding the Action

LoT Actions have three parts:

1. **Definition** — `DEFINE ACTION <name>`
2. **Trigger** — When to run (`ON EVERY <time>`, `ON TOPIC "<topic>"`, or `ON CHANGE "<topic>"` for value-change-only)
3. **Logic** — What to do (publish data, conditional logic, etc.)

Here's what we're building:

```lot Temperature Simulator wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION TemperatureSimulator
ON EVERY 5 SECONDS DO
    PUBLISH TOPIC "sensors/zone1/temperature" WITH "{\"temperature\": 72}"
```

| Line                                             | What it does                                                   |
| ------------------------------------------------ | -------------------------------------------------------------- |
| `DEFINE ACTION TemperatureSimulator`             | Creates an action named "TemperatureSimulator"                 |
| `ON EVERY 5 SECONDS DO`                          | Sets a time-based trigger (runs every 5 seconds)               |
| `PUBLISH TOPIC ... WITH "{\"temperature\": 72}"` | Publishes a JSON payload with temperature in Fahrenheit (72°F) |

<Note>
  Quotes inside strings must be escaped with backslashes (e.g. `"{\"temperature\": 72}"`).
</Note>

For a complete reference on triggers, operations, and advanced patterns, see the [Actions documentation](/v2.0/lot-language/actions/overview).

### Deploy the Action

<Tabs>
  <Tab title="Coreflux HUB" icon="globe">
    If you have the Coreflux HUB running—either as the Docker container with the HUB ports exposed, or the standalone desktop app for Windows or Linux—you can deploy actions directly from the HUB. See [Coreflux HUB Overview](/v2.0/coreflux-hub/overview) for full documentation.

    <Steps>
      <Step title="Open the HUB">
        In your browser, open `http://localhost:8080` if the broker runs on your machine, or `http://<broker-ip>:8080` using the IP address of the machine where the broker is running.
      </Step>

      <Step title="Go to LoT Editor">
        In the top navigation, select **LoT**, then **LoT Editor**, and open the **Actions** tab. Click **+ New Action**.

        <Frame caption="Opening the LoT Editor and creating a new action in Coreflux HUB">
          <img src="https://mintcdn.com/coreflux/W9CJ-kgVY3a3sCeL/images/add-new-action.gif?s=d28b1fb6422b63055687588fa0087244" alt="Animated walkthrough of opening the LoT Editor, selecting the Actions tab, and clicking New Action" width="800" height="500" data-path="images/add-new-action.gif" />
        </Frame>
      </Step>

      <Step title="Paste the Action Code">
        Paste the following code (no `-addAction` prefix needed—the HUB handles registration):

        ```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
        DEFINE ACTION TemperatureSimulator
        ON EVERY 5 SECONDS DO
            PUBLISH TOPIC "sensors/zone1/temperature" WITH "{\"temperature\": 72}"
        ```
      </Step>

      <Step title="Confirm Creation">
        You will see a confirmation and the action will appear in the Actions list. The action is now deployed and running on the broker.
      </Step>
    </Steps>
  </Tab>

  <Tab title="VS Code Extension" icon="code">
    <Tip>
      The VS Code extension provides syntax highlighting, auto-completion, and real-time validation for LoT actions. See the [LoT Notebooks Setup Guide](/v2.0/quick-start/vscode) for full installation and configuration details.
    </Tip>

    <Steps>
      <Step title="Ensure you have the LoT Notebooks extension installed">
        Open the extension panel, search for 'LoT Notebooks', and install.
      </Step>

      <Step title="Create a new LoT Notebook file">
        Click on File > New File..., give it it to a descriptive name (e.g., temperature-monitor).

        <Frame caption="Creating a new LoT Notebook file in VS Code">
          <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-lotnb-create-new.gif?s=6f76d28d7999e12459a044e460d414bc" alt="Animated walkthrough of creating a new .lotnb file in VS Code" width="1920" height="1032" data-path="images/extension/extension-lotnb-create-new.gif" />
        </Frame>
      </Step>

      <Step title="Connect to Your Broker">
        Enter your broker credentials (host, port, username, password) and click Connect.

        <Frame caption="Connecting to your Coreflux broker from VS Code">
          <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-broker-connect.gif?s=faf63084741fb786ec1807145f691a89" alt="Animated walkthrough of entering broker credentials and connecting in VS Code" width="1280" height="688" data-path="images/extension/extension-broker-connect.gif" />
        </Frame>

        <Accordion title="Default Broker Credentials">
          If you haven't changed your broker credentials, use these defaults:

          | Setting  | Value                               |
          | -------- | ----------------------------------- |
          | Host     | `localhost` or your server IP       |
          | Port     | `1883` (unencrypted) / `8883` (TLS) |
          | Username | `root`                              |
          | Password | `coreflux` (change immediately!)    |
        </Accordion>
      </Step>

      <Step title="Create a New Action">
        Create a new code block and add your code.

        <Frame caption="Creating a new LoT code cell in the notebook">
          <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-create-basic-action.gif?s=f0a99e24fb50a62f34539d706812f912" alt="Animated walkthrough of creating a new code block" width="1920" height="1032" data-path="images/extension/extension-create-basic-action.gif" />
        </Frame>
      </Step>

      <Step title="Paste the Action Code">
        ```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
        DEFINE ACTION TemperatureSimulator
        ON EVERY 5 SECONDS DO
            PUBLISH TOPIC "sensors/zone1/temperature" WITH "{\"temperature\": 72}"
        ```
      </Step>

      <Step title="Deploy">
        Click the **Run Button** on that specific cell to publish the action to your broker.

        <Frame caption="Running the LoT action from the notebook cell">
          <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-deploy-basic-action.gif?s=d7edcd18dc774cad66ff4969543e29ae" alt="Animated walkthrough of clicking the Run button to deploy the action to the broker" width="1920" height="1032" data-path="images/extension/extension-deploy-basic-action.gif" />
        </Frame>
      </Step>
    </Steps>
  </Tab>

  <Tab title="MQTT Client" icon="terminal">
    If you're using any external MQTT client, publish to the system command topic:

    <Steps>
      <Step title="Connect">
        Connect to your broker with your credentials.
      </Step>

      <Step title="Publish the Action">
        Publish the following to `$SYS/Coreflux/Command`:

        ```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
        -addAction DEFINE ACTION TemperatureSimulator
        ON EVERY 5 SECONDS DO
            PUBLISH TOPIC "sensors/zone1/temperature" WITH "{\"temperature\": 72}"
        ```
      </Step>

      <Step title="Check the Response">
        Subscribe to `$SYS/Coreflux/Command/Output` — you should see:

        ```text wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
        Action 'TemperatureSimulator' added successfully
        ```
      </Step>
    </Steps>

    <Note>
      Note the `-addAction` prefix — this tells Coreflux to register the action definition that follows.
    </Note>
  </Tab>
</Tabs>

### Verify It's Running

<Tabs>
  <Tab title="Coreflux HUB" icon="globe">
    If you deployed via the HUB, verify using the built-in Data Viewer. In the top navigation, select **MQTT**, then **Data Viewer**. In the Topic Tree, navigate to **sensors** → **zone1** → **temperature**. You should see `{"temperature": 72}` arriving every 5 seconds in the payload viewer.

    <Frame caption="Data Viewer showing live temperature messages on sensors/zone1/temperature">
      <img src="https://mintcdn.com/coreflux/W9CJ-kgVY3a3sCeL/images/mqtt-explorer-topic.png?fit=max&auto=format&n=W9CJ-kgVY3a3sCeL&q=85&s=1ea2485d3377208835e6698568d51191" alt="Coreflux HUB Data Viewer with the topic tree and live payload for a sensor temperature topic" width="1919" height="1199" data-path="images/mqtt-explorer-topic.png" />
    </Frame>
  </Tab>

  <Tab title="VS Code Extension" icon="code">
    The LoT extension automatically shows debug values for MQTT topics, so you can verify in two ways:

    <Steps>
      <Step title="Check the Actions list">
        If the action appears in your Actions list under the Coreflux Entities tab, it should be running.
      </Step>

      <Step title="Check live values in the extension">
        After deploying, the extension automatically subscribes to the action's topics and displays live MQTT messages. You should see temperature readings (e.g. `{"temperature": 72}`) on `sensors/zone1/temperature` arriving every 5 seconds.
      </Step>
    </Steps>

    <Frame caption="TemperatureSimulator action listed in the Coreflux Entities panel">
      <img src="https://mintcdn.com/coreflux/XSOUAWqOWS4Y2_FQ/images/extension/extension-verify-basic-action.gif?s=39e19beef3d939f9f6c9a2d5ceeb7d7b" alt="Coreflux Entities panel in VS Code showing TemperatureSimulator under the Actions list" width="1920" height="1032" data-path="images/extension/extension-verify-basic-action.gif" />
    </Frame>
  </Tab>

  <Tab title="MQTT Client" icon="terminal">
    Subscribe to `sensors/zone1/temperature`. You should see temperature readings arriving every 5 seconds:

    ```json wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
    {"temperature": 72}
    ```
  </Tab>
</Tabs>

**Congratulations!** Your first LoT Action is live.

## Example Real Scenario: Temperature Alarm

Now let's create a **reactive action** that transforms sensor data and checks thresholds. This demonstrates data transformation and conditional logic—common patterns in industrial monitoring.

<Info>
  This action runs **only when a message arrives** on `sensors/+/temperature`. After you deploy it, you will see no output until something publishes to that topic—for example, the Temperature Simulator from the previous section (if both are running), or a manual publish from the HUB Data Viewer or any MQTT client.
</Info>

Here's what the action does each time a new temperature reading arrives:

1. **Trigger** — The action fires whenever a message is published to any topic matching `sensors/+/temperature` (e.g. `sensors/zone1/temperature`).
2. **Extract** — It reads the `temperature` value (in Fahrenheit) from the incoming JSON payload.
3. **Convert** — It transforms Fahrenheit to Celsius using the standard formula: `(F − 32) × 5 / 9`.
4. **Decide** — If the Celsius value exceeds 35 °C, it publishes an alert to `alerts/high_temp`. Otherwise, it publishes the normalized Celsius reading to `sensors/normalized`.

```lot wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION TemperatureAlarm
ON TOPIC "sensors/+/temperature" DO
    SET "temp_f" WITH (GET JSON "temperature" IN PAYLOAD AS DOUBLE)
    SET "temp_c" WITH (({temp_f} - 32) * 5 / 9)
    IF {temp_c} > 35 THEN
        PUBLISH TOPIC "alerts/high_temp" WITH ("Alert: " + {temp_c} + "°C exceeds threshold")
    ELSE
        PUBLISH TOPIC "sensors/normalized" WITH {temp_c}
```

<Note>
  The `{}` denotes variable substitution, and expressions must be wrapped in parentheses. The `+` in the topic pattern is a single-level MQTT wildcard -- it matches any value in that position (e.g. `sensors/zone1/temperature`, `sensors/zone2/temperature`).
</Note>

### Deploy and Test

Deploy this action using the same method as above (Coreflux HUB, VS Code extension, or MQTT client). Once deployed, use the steps below to verify reactive logic.

### How to Test the Logic

The action subscribes to any topic matching `sensors/+/temperature` (e.g. `sensors/zone1/temperature`). It expects a JSON payload with a `temperature` key (Fahrenheit). It then converts to Celsius and either publishes an alert (if > 35°C) or the normalized value.

| Role                | Topic                       | Description                                                          |
| ------------------- | --------------------------- | -------------------------------------------------------------------- |
| **Input**           | `sensors/zone1/temperature` | Publish test payloads here (must match `sensors/+/temperature`)      |
| **Output (normal)** | `sensors/normalized`        | Receives the Celsius value when temperature is at or below 35°C      |
| **Output (alert)**  | `alerts/high_temp`          | Receives the alert message when temperature exceeds 35°C (e.g. 95°F) |

**Sample payloads (copy-paste):**

* **Below threshold** — publish to `sensors/zone1/temperature`:
  ```json wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
  {"temperature": 77}
  ```
  Expect: a message on `sensors/normalized` with the Celsius value (about 25).
* **Above threshold** — publish to `sensors/zone1/temperature`:
  ```json wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
  {"temperature": 95}
  ```
  Expect: a message on `alerts/high_temp` with text like "Alert: 35°C exceeds threshold".

<Tabs>
  <Tab title="Coreflux HUB" icon="globe">
    <Steps>
      <Step title="Deploy the Temperature Alarm action">
        In **LoT** → **LoT Editor** → **Actions**, create a new action or open an existing one, paste the Temperature Alarm code, and save. Confirm it appears in the Actions list.
      </Step>

      <Step title="Open the Data Viewer">
        Select **MQTT** → **Data Viewer**. In the Topic Tree, watch `sensors/normalized` and `alerts/high_temp` (add them to your tracked view if needed).

        <Frame caption="Coreflux HUB Data Viewer — Publish panel, Topic Tree, and live topic details">
          <img src="https://mintcdn.com/coreflux/W9CJ-kgVY3a3sCeL/images/mqtt-explorer-overview.png?fit=max&auto=format&n=W9CJ-kgVY3a3sCeL&q=85&s=f9299f752c8f7b52c8e5948edaa0d67c" alt="Coreflux HUB Data Viewer with the Publish panel on the left, Topic Tree in the center, and a tracked topic with live values on the right" width="1024" height="639" data-path="images/mqtt-explorer-overview.png" />
        </Frame>
      </Step>

      <Step title="Send test data">
        In the **Publish** panel, set the topic to `sensors/zone1/temperature` and paste one of the sample JSON payloads above. Click publish. If the Temperature Simulator is still running, it already publishes every 5 seconds—you will see results on `sensors/normalized` (72°F is below 35°C).
      </Step>

      <Step title="Confirm output">
        Select the output topic in the tree and verify the payload in the viewer (normalized value or alert text).
      </Step>
    </Steps>
  </Tab>

  <Tab title="VS Code Extension" icon="code">
    <Steps>
      <Step title="Deploy the Temperature Alarm action">
        Paste the action code in a LoT cell and run it. Confirm success in the Actions list.
      </Step>

      <Step title="Observe output topics">
        After deploying, the extension automatically subscribes to the action's output topics and displays their values. Look for messages on `sensors/normalized` and `alerts/high_temp` once test data is published.
      </Step>

      <Step title="Send test data">
        Use the HUB Data Viewer, the VS Code extension publish tools, or any MQTT client to publish one of the sample JSON payloads above to `sensors/zone1/temperature`. If the Temperature Simulator from the previous section is still running, it already publishes every 5 seconds and you will see results on `sensors/normalized` (72°F is below 35°C). Check the topic tree displayed below the code cell to see incoming values update in real time.
      </Step>

      <Step title="Confirm output">
        Check that the corresponding output topic received the expected message (normalized value or alert).
      </Step>
    </Steps>
  </Tab>

  <Tab title="MQTT Client" icon="terminal">
    <Steps>
      <Step title="Deploy the Temperature Alarm action">
        Publish the action to `$SYS/Coreflux/Command` with the `-addAction` prefix. Confirm "Action 'TemperatureAlarm' added successfully" on `$SYS/Coreflux/Command/Output`.
      </Step>

      <Step title="Subscribe to output topics">
        Subscribe to `sensors/normalized` and `alerts/high_temp` so you can see responses.
      </Step>

      <Step title="Publish a test payload">
        Publish to topic `sensors/zone1/temperature` with payload `{"temperature": 77}` or `{"temperature": 95}` (use one of the sample payloads above).
      </Step>

      <Step title="Confirm output">
        You should see a message on `sensors/normalized` (for 77°F) or on `alerts/high_temp` (for 95°F).
      </Step>
    </Steps>
  </Tab>
</Tabs>

This confirms your broker transforms data and applies conditional logic in real time.

### Clean Up (Optional)

To remove the test action:

<Tabs>
  <Tab title="Coreflux HUB" icon="globe">
    In **LoT** → **LoT Editor** → **Actions**, select the action in the list and use the **delete** control. Confirm deletion—the action is removed from the broker immediately.

    <Frame caption="Deleting an action in the Coreflux HUB LoT Editor">
      <img src="https://mintcdn.com/coreflux/W9CJ-kgVY3a3sCeL/images/delete-an-action.gif?s=6e6d9a1e444c7dfc808899e327d30c02" alt="Animated walkthrough of selecting and deleting an Action in the LoT Editor" width="800" height="500" data-path="images/delete-an-action.gif" />
    </Frame>
  </Tab>

  <Tab title="VS Code Extension" icon="code">
    On the Coreflux Entities tab, right-click the desired action in your Actions list and select **"Remove"**.
  </Tab>

  <Tab title="MQTT Client" icon="terminal">
    Publish to `$SYS/Coreflux/Command`:

    ```text wrap theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
    -removeAction TemperatureAlarm
    ```
  </Tab>
</Tabs>

## Quick Examples

Looking for inspiration? Check out the [**Language of Things Training Repository**](https://github.com/CorefluxCommunity/Language-Of-Things-Training) for common patterns like:

* **Topic-Based Triggers**: Echo messages between topics
* **State Machines**: Toggle switches and conditional logic
* **Event Counters**: Track and aggregate system events

<Card title="Language of Things Training" icon="github" href="https://github.com/CorefluxCommunity/Language-Of-Things-Training">
  Explore a collection of ready-to-use LoT Action examples and templates.
</Card>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Action not executing?">
    * Verify the broker is running and you're connected
    * Check `$SYS/Coreflux/Command/Output` for error messages
    * Ensure proper indentation in your LoT action (use consistent tabs or spaces)
    * Confirm the action appears in `$SYS/Coreflux/Actions` or in the HUB LoT Editor Actions list
  </Accordion>

  <Accordion title="Can't connect to the broker?">
    * Verify the broker hostname/IP and port are correct
    * Check that port 1883 (or 8883 for TLS) is open
    * Confirm your username and password are correct
    * If using TLS, ensure certificates are properly configured
  </Accordion>

  <Accordion title="Messages not appearing on subscribed topics?">
    * Verify you're subscribed to the exact topic (including case sensitivity)
    * Check if any Rules are blocking access to the topic
    * Use wildcards (`+` or `#`) to debug topic hierarchies
  </Accordion>
</AccordionGroup>

## Next Steps

Now that you have a working setup, explore the core LoT components:

<CardGroup cols={2}>
  <Card title="Actions" icon="bolt" href="/v2.0/lot-language/actions/syntax">
    React to events and publish data. Create time-based automations or respond to topic changes.
  </Card>

  <Card title="Introduction to LoT" icon="book" href="/v2.0/lot-language/introduction">
    Understand the core concepts and architecture of the Language of Things.
  </Card>
</CardGroup>
