event logo
Kaa Documentation

Rule Engine Architecture

Written by Andrew Pasika

Architecture Overview

As mentioned in the Rule Engine Getting Started, the Rule Engine is a tool that allows you to create automated actions based on specific conditions or events generated by IoT devices.

The Rule Engine is built on three parts: trigger, rule, and action.

Architecture overview

Trigger

A trigger is an event or condition monitor that initiates rule execution. In other words, a trigger listens for events of a particular type and, once it occurs (e.g., the device posts data sample), it executes the attached rule(s).

See triggers to learn more about triggers and their types.

Rule

A JavaScript expression that is executed for the endpoint on which trigger observed an event. Usually, a rule returns some value, and based on this value, the Rule Engine decides which actions to execute — Positive, Negative, or no actions at all.

Action

An action is an operation performed after a rule is executed and returned a value. Like a trigger, an action is attached to a rule. There are two types of actions: Positive and Negative. Positive actions are executed if the rule returns true or any other value except false, null, or undefined. Negative actions are executed if the rule returns false. No actions are executed if the rule returns null or undefined.

Let’s put this into an example:

  • Trigger: The device posted data sample with a temperature in it.
  • Rule: The temperature value is greater than 30°C.
  • Positive Action: Send an email.

Next Steps