Skip to main content
The Rules Engine is the heart of EngageFabric’s automation. Define rules that automatically trigger actions when events occur.

How It Works

Rule Structure

Every rule consists of:
  • Trigger: The event that activates the rule
  • Conditions: Optional filters to check before executing
  • Actions: What happens when conditions are met
{
  "name": "Award XP for lesson completion",
  "trigger": {
    "event": "lesson_completed"
  },
  "conditions": [
    {
      "type": "property_equals",
      "property": "properties.passed",
      "value": true
    }
  ],
  "actions": [
    {
      "type": "GRANT_XP",
      "amount": 100
    },
    {
      "type": "PROGRESS_QUEST",
      "questId": "complete-10-lessons"
    }
  ]
}

Condition Types

Check if an event property equals a specific value.
{
  "type": "property_equals",
  "property": "properties.category",
  "value": "premium"
}
Check if a numeric property exceeds a threshold.
{
  "type": "property_greater_than",
  "property": "properties.score",
  "value": 80
}
Check if a numeric property is below a threshold.
{
  "type": "property_less_than",
  "property": "properties.errors",
  "value": 3
}
Check the player’s current level.
{
  "type": "player_level_equals",
  "value": 10
}
Check if player has reached a minimum level.
{
  "type": "player_level_greater_than",
  "value": 5
}
Only trigger during specific times.
{
  "type": "time_window",
  "startHour": 9,
  "endHour": 17,
  "timezone": "UTC"
}
Only trigger the first time this event occurs for the player.
{
  "type": "first_time"
}
Limit how often a rule can trigger for a player.
{
  "type": "cooldown",
  "minutes": 60
}

Action Types

Award experience points to the player.
{
  "type": "GRANT_XP",
  "amount": 100
}
Award virtual currency.
{
  "type": "GRANT_CURRENCY",
  "currencyId": "coins",
  "amount": 50
}
Award a badge to the player.
{
  "type": "GRANT_BADGE",
  "badgeId": "first-purchase"
}
Increment progress on a quest.
{
  "type": "PROGRESS_QUEST",
  "questId": "complete-10-lessons",
  "amount": 1
}
Make a quest available to the player.
{
  "type": "UNLOCK_QUEST",
  "questId": "advanced-challenges"
}
Update a player’s leaderboard score.
{
  "type": "UPDATE_LEADERBOARD",
  "leaderboardId": "weekly-xp",
  "score": "${player.xp}"
}
Send a push notification or in-app message.
{
  "type": "SEND_NOTIFICATION",
  "title": "Achievement Unlocked!",
  "message": "You've completed your first quest!"
}
Emit a custom event (can trigger other rules).
{
  "type": "EMIT_EVENT",
  "eventName": "milestone_reached",
  "properties": {
    "milestone": "first_purchase"
  }
}

Dynamic Values

Use dynamic values in actions with template syntax:
VariableDescription
${player.id}Player’s ID
${player.xp}Player’s current XP
${player.level}Player’s current level
${event.name}Triggering event name
${event.properties.X}Event property value
Example:
{
  "type": "GRANT_XP",
  "amount": "${event.properties.score * 10}"
}

Rule Priority

When multiple rules can trigger from the same event, they execute in priority order:
{
  "name": "High priority rule",
  "priority": 100,
  "trigger": { "event": "purchase_completed" }
}
Higher priority numbers execute first.

Testing Rules

Use the Rules Sandbox in the Admin Console to test rules before deploying:
  1. Select a rule to test
  2. Provide a mock event payload
  3. See which actions would execute
  4. Verify conditions are evaluated correctly
Always test rules in a staging environment before deploying to production. Use test API keys and test players to verify behavior.

Best Practices

Keep rules simple

One rule should do one thing well. Chain multiple rules for complex logic.

Use meaningful names

Name rules clearly so team members understand their purpose.

Add cooldowns

Prevent abuse by adding cooldowns to high-reward rules.

Test thoroughly

Use the sandbox and staging environments before production.