Rule engine
Write if-then-else rules declaratively. The engine evaluates each rule against incoming events and fires actions.
What you'll learn
- When to use the rule engine vs. workflow vs. event consumer
- The rule DSL
- Pluggable conditions and actions
When to use the rule engine
Use it when your logic is mostly:
- If
<event matches some pattern>and<some condition>then<do thing>
If you have many rules that share conditions and actions, or end users need to author rules in a UI, this is the right tool. If you need branching logic with state, use a Workflow. If you just need to react to an event, use an event consumer.
Rule shape
name: high-value-deal-alert
when:
event: invoice.paid
conditions:
- field: amount
gte: 10000
- field: currency
eq: USD
then:
- action: notification.send
args:
channel: '#deals'
template: 'high-value-deal'
Authoring rules
- In the web app: Developer Console → Rules → New Rule (visual builder)
- As code: PUT rules via the GraphQL API for version control
Pluggable conditions and actions
Both are extension points. Register new ones from your service module or via a plugin:
import { registerCondition, registerAction } from '@burdenoff/platform-sdk/rules';
registerCondition('hasTag', async (ctx, { tag }) => {
return ctx.event.tags?.includes(tag);
});
registerAction('jira.createIssue', async (ctx, { project, summary }) => {
await jira.issues.create({ project, summary });
});