Condition
Branch a contact down one of two paths based on event or contact data.
A condition step evaluates a rule against event or contact data and routes the automation down one of two paths: condition met or condition not met. See Using automations for the surrounding workflow.
Common use cases:
- Plan-based emails — send different content to free vs. paid users.
- Engagement splits — take different actions based on user activity.
- Personalization — tailor follow-ups based on event payload values.
How it works
The condition step accepts a type and the corresponding rule fields, plus two outgoing connections — one for each outcome.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.automations.create({
"name": "Plan-based welcome",
"domain": "yourdomain.com",
"steps": [
{ "key": "start", "type": "trigger", "config": { "event_name": "user.created" } },
{
"key": "check_plan",
"type": "condition",
"config": { "type": "rule", "field": "event.plan", "operator": "eq", "value": "pro" }
},
{ "key": "send_pro_email", "type": "send_email", "config": { "template": { "id": "pro-welcome-template-id" } } },
{ "key": "send_free_email", "type": "send_email", "config": { "template": { "id": "free-welcome-template-id" } } }
],
"connections": [
{ "from": "start", "to": "check_plan", "type": "default" },
{ "from": "check_plan", "to": "send_pro_email", "type": "condition_met" },
{ "from": "check_plan", "to": "send_free_email", "type": "condition_not_met" }
]
});
console.log({ data, error });Connection types
A condition step always produces two outgoing connections:
| Connection type | Description |
|---|---|
condition_met | Taken when the condition evaluates to true. |
condition_not_met | Taken when the condition evaluates to false. |
Operators
A rule condition compares a field against a value using one of the following operators:
| Operator | Meaning |
|---|---|
eq | Equals. |
neq | Not equals. |
gt | Greater than. |
gte | Greater than or equal to. |
lt | Less than. |
lte | Less than or equal to. |
contains | Contains a given value. |
starts_with | Starts with a given value. |
ends_with | Ends with a given value. |
exists | Field exists (no value required). |
is_empty | Field is empty (no value required). |
Combining rules
Use and or or to combine multiple rules into a single branch. Each entry in rules is itself a condition config — including nested and/or groups.
{
"key": "check_plan_and_amount",
"type": "condition",
"config": {
"type": "and",
"rules": [
{ "type": "rule", "field": "event.plan", "operator": "eq", "value": "pro" },
{ "type": "rule", "field": "event.amount", "operator": "gte", "value": 100 }
]
}
}Configuration
config.typestringrequiredThe type of condition node: rule, and, or or.
config.fieldstringrequiredFor rule type — the field to evaluate. Must use the event. or contact. namespace prefix (e.g. event.amount, contact.email).
config.operatorstringrequiredFor rule type — the comparison operator. See the operators table above.
config.valuestring | number | boolean | nulloptionalFor rule type — the value to compare against. Not required for exists and is_empty.
config.rulesobject[]optionalFor and / or types — an array of nested condition config objects. Must contain at least one item.