Create New Rule

To create a new Rule, open the Rule Tab in Events section.

Steps to Create a Rule

  1. Click on the Add Rule button
  2. Fill in the details to create rule instantly:
PROPERTYTYPEREQUIREDDESCRIPTION
KeyStringYesRule identifier. Use snake_case format. Example: high_value_customer
EntityId FieldStringYesIts grouping key on which you want aggreagation, eg. device_id, user_id, flight_id, This will always be in snake case
DescriptionStringNoDescription helps to understand the rule's purpose
TagsDropdownNoTags to categorize rules. You can manage tags in the company profile section
ExpressionStringYesRule expression. For example- if the number of orders in the last 24 hours is > 10, consider it as high-value customer. The rule expression would be: no_of_orders_24h >10 See Logical Expression for syntax details.
Note: All signals used in filter expression must have same entity Id field that of this rule.

Evaluating Rules

To determine whether a rule evaluates to true or false for a specific user, you can evaluate the rule using either the Datablit SDK or direct API calls.

Method 1: Using Datablit SDK

The recommended approach is to use the Datablit SDK for your platform. Check out the Datablit Sources documentation and navigate to your platform's specific implementation.

Method 2: Direct API Call

sh
curl --location 'https://api.datablit.com/api/1.0/rule/eval' \
--header 'apiKey: 01JSWDEZYM0E19ZF3RMHS75PB1' \
--header 'Content-Type: application/json' \
--data '{
    "key": "high_value_customer",
    "entity_id": "1",
    "params": {
        "os_name": "android"
    }
}'

Parameters

  • key: The rule key identifier
  • entity_id: The entity Id value to evaluate the rule for
  • params: Optional parameters that can be referenced in the rule expression

Using Parameters in Rules

You can pass optional parameters in JSON format and reference them inside the rule:

json
{
  "os_name": "android",
  "user_plan": "premium"
}

Inside the rule expression, you can reference these parameters:

go
no_of_orders_24h > 10 && os_name == 'android'

Method 3: Console Evaluation

You can also test rules directly in the Datablit Console:

  1. Navigate to the Rules section in your project
  2. Click on the three dots next to your rule and select "Evaluate"
  3. Enter the user_id and any optional parameters
  4. Click submit to see the evaluation result (true or false)