Kafka triggered temperature warning

    Polling Telegram for a response: https://n8dex.com/iqU3AqV3

    Shared 11/9/2025

    179 views

    Visual Workflow

    JSON Code

    {
      "id": "ytlGJsaFSlUpaKZ0",
      "meta": {
        "instanceId": "9a93705676cef812bba4609ac2e211f44c4c6a4ffff0d6ade780528db2a298ee",
        "templateCredsSetupCompleted": true
      },
      "name": "TemperatureRecommender",
      "tags": [],
      "nodes": [
        {
          "id": "f5370024-63d8-4722-bc3b-20d74c7a921e",
          "name": "Kafka Trigger",
          "type": "n8n-nodes-base.kafkaTrigger",
          "position": [
            0,
            0
          ],
          "parameters": {
            "topic": "temperature",
            "groupId": "temperature",
            "options": {}
          },
          "credentials": {
            "kafka": {
              "id": "CybK8N44uv1ObT7K",
              "name": "Kafka Credentials"
            }
          },
          "typeVersion": 1.1
        },
        {
          "id": "de0de1a8-9a0a-422b-9df8-94397fa90133",
          "name": "No Operation, do nothing",
          "type": "n8n-nodes-base.noOp",
          "position": [
            624,
            112
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "id": "8c52e16c-3149-41f0-8997-3eb1520fa6bd",
          "name": "Get Temperature from Kafka Event",
          "type": "n8n-nodes-base.code",
          "position": [
            208,
            0
          ],
          "parameters": {
            "mode": "runOnceForEachItem",
            "language": "python",
            "pythonCode": "import json\n\nreturn {'temperatureValue': json.loads(_input.item.json.message).get('valuse', 0.0) }"
          },
          "typeVersion": 2
        },
        {
          "id": "26a6aae8-775d-4413-b174-6b224d8161aa",
          "name": "Send Call for Action",
          "type": "n8n-nodes-base.telegram",
          "position": [
            816,
            -128
          ],
          "webhookId": "299c1520-bd5a-4549-bc70-833dd2bfe29b",
          "parameters": {
            "text": "=**Temperature Warning:**\nthe temperature is **outside** of the safe range: [15°C, 30°C]: {{ $json.temperatureValue.toFixed(1) }}°C - **Action required**",
            "chatId": "1977426158",
            "replyMarkup": "replyKeyboard",
            "replyKeyboard": {
              "rows": [
                {
                  "row": {
                    "buttons": [
                      {
                        "text": "Take action",
                        "additionalFields": {}
                      },
                      {
                        "text": "Ignore",
                        "additionalFields": {}
                      }
                    ]
                  }
                }
              ]
            },
            "additionalFields": {
              "parse_mode": "Markdown"
            },
            "replyKeyboardOptions": {}
          },
          "credentials": {
            "telegramApi": {
              "id": "FNTwo6Hbbk8ctqyO",
              "name": "Telegram account"
            }
          },
          "typeVersion": 1.2
        },
        {
          "id": "86c602c6-4dbc-4ec4-a576-7a757206d087",
          "name": "Wait for Response",
          "type": "n8n-nodes-base.executeWorkflow",
          "position": [
            992,
            -128
          ],
          "parameters": {
            "mode": "each",
            "options": {
              "waitForSubWorkflow": true
            },
            "workflowId": {
              "__rl": true,
              "mode": "list",
              "value": "4P8H2RU4oIHlQJN0",
              "cachedResultUrl": "/workflow/4P8H2RU4oIHlQJN0",
              "cachedResultName": "WaitTelegramResponse"
            },
            "workflowInputs": {
              "value": {},
              "schema": [
                {
                  "id": "ok",
                  "type": "boolean",
                  "display": true,
                  "removed": false,
                  "required": false,
                  "displayName": "ok",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                },
                {
                  "id": "result",
                  "type": "object",
                  "display": true,
                  "removed": false,
                  "required": false,
                  "displayName": "result",
                  "defaultMatch": false,
                  "canBeUsedToMatch": true
                }
              ],
              "mappingMode": "defineBelow",
              "matchingColumns": [],
              "attemptToConvertTypes": false,
              "convertFieldsToString": true
            }
          },
          "executeOnce": true,
          "typeVersion": 1.3
        },
        {
          "id": "08a59580-5c8a-4c03-95e8-2ba40a4e0e31",
          "name": "If Temperature is abnormal",
          "type": "n8n-nodes-base.if",
          "position": [
            416,
            0
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "loose"
              },
              "combinator": "or",
              "conditions": [
                {
                  "id": "2c129d14-ffc1-41de-88c3-8d34f877619b",
                  "operator": {
                    "type": "number",
                    "operation": "gt"
                  },
                  "leftValue": "={{ $json.temperatureValue }}",
                  "rightValue": 30
                },
                {
                  "id": "fb25caca-71d1-4483-a5eb-7fd929f89268",
                  "operator": {
                    "type": "number",
                    "operation": "lt"
                  },
                  "leftValue": "={{ $json.temperatureValue }}",
                  "rightValue": 15
                }
              ]
            },
            "looseTypeValidation": true
          },
          "typeVersion": 2.2
        },
        {
          "id": "7b12544c-8868-4b16-8905-88d23ebda8be",
          "name": "If Action should be taken",
          "type": "n8n-nodes-base.if",
          "position": [
            1168,
            -128
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "052df846-7893-4c48-85a8-004e52934db3",
                  "operator": {
                    "name": "filter.operator.equals",
                    "type": "string",
                    "operation": "equals"
                  },
                  "leftValue": "={{ $json.response }}",
                  "rightValue": "Take action"
                }
              ]
            }
          },
          "typeVersion": 2.2
        }
      ],
      "active": false,
      "pinData": {},
      "settings": {
        "executionOrder": "v1"
      },
      "versionId": "567b4311-5a36-4546-a325-10f4c82a0e52",
      "connections": {
        "Kafka Trigger": {
          "main": [
            [
              {
                "node": "Get Temperature from Kafka Event",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Wait for Response": {
          "main": [
            [
              {
                "node": "If Action should be taken",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Send Call for Action": {
          "main": [
            [
              {
                "node": "Wait for Response",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "If Temperature is abnormal": {
          "main": [
            [
              {
                "node": "Send Call for Action",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "No Operation, do nothing",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Get Temperature from Kafka Event": {
          "main": [
            [
              {
                "node": "If Temperature is abnormal",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }