{
  "ruleChain": {
    "name": "Send Alarm Email to Customer",
    "type": "CORE",
    "firstRuleNodeId": null,
    "root": false,
    "debugMode": false,
    "configuration": null,
    "additionalInfo": {
      "description": ""
    }
  },
  "metadata": {
    "version": 9,
    "firstNodeIndex": 0,
    "nodes": [
      {
        "type": "org.thingsboard.rule.engine.filter.TbJsFilterNode",
        "name": "Check Temperature Range",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "return msg.temperature > 20;",
          "tbelScript": "return msg.temperature < -15 || msg.temperature > 30;"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 172,
          "layoutY": 255
        }
      },
      {
        "type": "org.thingsboard.rule.engine.metadata.TbGetCustomerAttributeNode",
        "name": "Get Customer Email",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 2,
        "configuration": {
          "dataToFetch": "ATTRIBUTES",
          "dataMapping": {
            "email": "customerEmail"
          },
          "fetchTo": "METADATA",
          "preserveOriginatorIfCustomer": false
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 302,
          "layoutY": 152
        }
      },
      {
        "type": "org.thingsboard.rule.engine.metadata.TbGetAttributesNode",
        "name": "Get Device Address",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 1,
        "configuration": {
          "tellFailureIfAbsent": true,
          "fetchTo": "METADATA",
          "clientAttributeNames": [],
          "sharedAttributeNames": [],
          "serverAttributeNames": [
            "address"
          ],
          "latestTsKeyNames": [],
          "getLatestValueWithTs": false
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 448,
          "layoutY": 255
        }
      },
      {
        "type": "org.thingsboard.rule.engine.action.TbCreateAlarmNode",
        "name": "Create Temperature Alarm",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "alarmDetailsBuildJs": "var details = {};\nif (metadata.prevAlarmDetails) {\n    details = JSON.parse(metadata.prevAlarmDetails);\n    //remove prevAlarmDetails from metadata\n    delete metadata.prevAlarmDetails;\n    //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;",
          "alarmDetailsBuildTbel": "var details = {};\nif (metadata.prevAlarmDetails != null) {\n    details = JSON.parse(metadata.prevAlarmDetails);\n    //remove prevAlarmDetails from metadata\n    metadata.remove('prevAlarmDetails');\n    //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;",
          "useMessageAlarmData": false,
          "overwriteAlarmDetails": false,
          "alarmType": "High Temperature",
          "severity": "CRITICAL",
          "propagate": false,
          "relationTypes": [],
          "propagateToOwner": false,
          "propagateToOwnerHierarchy": false,
          "propagateToTenant": false,
          "dynamicSeverity": false
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 704,
          "layoutY": 250
        }
      },
      {
        "type": "org.thingsboard.rule.engine.mail.TbMsgToEmailNode",
        "name": "Build Email",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "fromTemplate": "no-reply@example.com",
          "toTemplate": "${customerEmail}",
          "ccTemplate": "",
          "bccTemplate": "",
          "subjectTemplate": "Temperature alert on device ${deviceName}",
          "mailBodyType": "false",
          "bodyTemplate": "Device ${deviceName} has an unacceptable temperature: ${temperature}°C.\nDevice address: ${ss_address}"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 702,
          "layoutY": 355
        }
      },
      {
        "type": "org.thingsboard.rule.engine.mail.TbSendEmailNode",
        "name": "Send Email",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424313645
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "useSystemSmtpSettings": true,
          "smtpHost": "localhost",
          "smtpPort": 25,
          "username": null,
          "password": null,
          "smtpProtocol": "smtp",
          "timeout": 10000,
          "enableTls": false,
          "tlsVersion": "TLSv1.2",
          "enableProxy": false,
          "proxyHost": null,
          "proxyPort": null,
          "proxyUser": null,
          "proxyPassword": null
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 702,
          "layoutY": 454
        }
      },
      {
        "type": "org.thingsboard.rule.engine.transform.TbTransformMsgNode",
        "name": "Add Temperature to Metadata",
        "debugSettings": {
          "failuresEnabled": true,
          "allEnabled": false,
          "allEnabledUntil": 1776424866399
        },
        "singletonMode": false,
        "queueName": null,
        "configurationVersion": 0,
        "configuration": {
          "scriptLang": "TBEL",
          "jsScript": "metadata.temperature = msg.temperature;\nreturn {msg: msg, metadata: metadata, msgType: msgType};",
          "tbelScript": "metadata.temperature = msg.temperature;\nreturn {msg: msg, metadata: metadata, msgType: msgType};"
        },
        "additionalInfo": {
          "description": "",
          "layoutX": 576,
          "layoutY": 153
        }
      }
    ],
    "connections": [
      {
        "fromIndex": 0,
        "toIndex": 1,
        "type": "True"
      },
      {
        "fromIndex": 1,
        "toIndex": 2,
        "type": "Success"
      },
      {
        "fromIndex": 2,
        "toIndex": 6,
        "type": "Success"
      },
      {
        "fromIndex": 3,
        "toIndex": 4,
        "type": "Created"
      },
      {
        "fromIndex": 4,
        "toIndex": 5,
        "type": "Success"
      },
      {
        "fromIndex": 6,
        "toIndex": 3,
        "type": "Success"
      }
    ],
    "ruleChainConnections": null
  }
}