AutomationFlowsGeneral › Iot Device Control with Mqtt and Webhook

Iot Device Control with Mqtt and Webhook

ByTony Duffy @tduffy on n8n.io

.

Webhook trigger★★☆☆☆ complexity6 nodesMqtt
General Trigger: Webhook Nodes: 6 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #4211 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "01UHgh673YDyv5xN",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "IOT control via MQTT and webhook",
  "tags": [],
  "nodes": [
    {
      "id": "3d3b2e80-4e4e-43ec-b2fd-7000e7307915",
      "name": "MQTT Publish Topic Node",
      "type": "n8n-nodes-base.mqtt",
      "position": [
        680,
        -20
      ],
      "parameters": {
        "topic": "pin-control",
        "message": "={{ $json.pin }}",
        "options": {},
        "sendInputData": false
      },
      "credentials": {
        "mqtt": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f4444f19-424a-487b-8d7c-3c609a55b913",
      "name": "Set data for MQTT message payload",
      "type": "n8n-nodes-base.set",
      "position": [
        360,
        -20
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "pin",
              "value": "={{ $json.query.value }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "id": "3ed996b8-419f-458a-a717-b35e1a52a851",
      "name": "IOT control Webhook ",
      "type": "n8n-nodes-base.webhook",
      "position": [
        20,
        -20
      ],
      "parameters": {
        "path": "pin-control",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "40fa6c2a-c515-412b-93df-eceb993c38c9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -160
      ],
      "parameters": {
        "height": 120,
        "content": "When the \"on\" or \"off\" button is clicked on the IOT control webpage the webhook gets the selected value and triggers the workflow "
      },
      "typeVersion": 1
    },
    {
      "id": "159f8c6e-285a-443a-bd9d-ae3456b9a6a8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -140
      ],
      "parameters": {
        "height": 80,
        "content": "The set node prepares the receive data as a message payload for the MQTT topic"
      },
      "typeVersion": 1
    },
    {
      "id": "250140e6-f46c-42c2-b79a-537ec4975b97",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "height": 100,
        "content": "Publishes MQTT topic \"pin-control\" with the payload data to control the GPIO on the ESP32 microcontroller"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f5d124a9-c6e1-44f5-b088-cafb8e5bd602",
  "connections": {
    "IOT control Webhook ": {
      "main": [
        [
          {
            "node": "Set data for MQTT message payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set data for MQTT message payload": {
      "main": [
        [
          {
            "node": "MQTT Publish Topic Node",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

.

Source: https://n8n.io/workflows/4211/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

HR tool. Uses googleSheets. Webhook trigger; 12 nodes.

Google Sheets
General

This workflow receives inbound emails from EmailConnect.eu via an n8n webhook, extracts key message fields, drops spam, and routes emails to different downstream paths based on the recipient alias (fo

General

Create_Unique_Jira_tickets_from_Splunk_alerts. Uses jira. Webhook trigger; 11 nodes.

Jira
General

Http Stickynote. Uses stickyNote, httpRequest, highLevel. Webhook trigger; 10 nodes.

HTTP Request, High Level
General

Http Keap. Uses stickyNote, httpRequest, keap. Webhook trigger; 10 nodes.

HTTP Request, Keap