Enrichment Rules
Enrichment rules are the heart of Ledly’s lead processing engine. They allow you to automatically transform, enrich, route, and filter leads based on configurable conditions.
What Are Enrichment Rules?
Enrichment rules are conditional logic blocks that execute when a lead matches specific criteria. Each rule consists of:
- Conditions - When should this rule apply?
- Actions - What should happen when conditions are met?
- Priority - In what order should rules execute?
Rule Components
Conditions
Conditions determine when a rule should fire. You can combine multiple conditions with AND/OR logic.
| Condition Type | Description | Example |
|---|---|---|
| Field Equals | Exact match | state = "California" |
| Field Contains | Partial match | email contains "@edu" |
| Field Starts With | Prefix match | phone starts with "+1" |
| Field Ends With | Suffix match | email ends with ".edu" |
| Field Is Empty | No value | company is empty |
| Field Is Not Empty | Has any value | phone is not empty |
| Field Greater Than | Numeric comparison | age > 18 |
| Field Less Than | Numeric comparison | score < 50 |
| Field In List | One of many values | state in ["CA", "NY", "TX"] |
| Field Matches Regex | Pattern match | email matches ".*@university\.edu" |
Actions
Actions define what happens when conditions are met.
| Action Type | Description | Use Case |
|---|---|---|
| Set Field | Set a field to a value | Assign lead source, set defaults |
| Transform Field | Modify existing value | Uppercase name, format phone |
| Calculate Field | Compute from other fields | Full name from first + last |
| Reject Lead | Stop processing, reject | Filter out invalid leads |
| Flag for Review | Mark for manual review | Suspicious leads |
| Trigger Webhook | Call external API | Third-party enrichment |
| Set Program | Assign to program | Route to correct program |
| Stop Processing | Skip remaining rules | First-match-wins logic |
Creating Enrichment Rules
Navigate to Rules
Go to Settings → Enrichment Rules
Click Add Rule
Click the Add Rule button in the top right
Configure Conditions
Add one or more conditions. Use the Add Condition button to add more, and select AND or OR logic.
Configure Actions
Add one or more actions to execute when conditions match.
Set Priority
Drag rules to reorder. Lower numbers execute first.
Save and Test
Click Save, then use the Test Rule feature to verify behavior.
Rule Examples
Example 1: Auto-Assign Lead Source
Goal: Set the lead source to “Website” for all leads from web forms.
Condition: source is empty AND vendor = "web-form"
Action: Set field "source" to "Website"Example 2: Reject Disposable Emails
Goal: Reject leads with disposable email addresses.
Condition: email ends with "@mailinator.com"
OR email ends with "@tempmail.com"
OR email ends with "@guerrillamail.com"
Action: Reject lead with reason "Disposable email address"Example 3: Enrich State from Zip Code
Goal: Use a lookup table to set the state based on zip code.
Condition: state is empty AND zip_code is not empty
Action: Lookup "state" from table "zip_to_state" using "zip_code"Example 4: Calculate Full Name
Goal: Combine first and last name into a full name field.
Condition: first_name is not empty AND last_name is not empty
Action: Calculate field "full_name" = "{{first_name}} {{last_name}}"Example 5: Route to Specific Program
Goal: Route MBA-interested leads to the MBA program.
Condition: program_interest contains "MBA"
OR program_interest contains "Business"
Action: Set field "program_code" to "MBA-ONLINE"
Action: Set field "assigned_rep" to "[email protected]"Example 6: External Enrichment via Webhook
Goal: Call an external API to enrich lead data.
Condition: email is not empty AND enrichment_status is empty
Action: Trigger webhook "https://api.enrichment-service.com/enrich"
with payload { "email": "{{email}}" }
Action: Set field "enrichment_status" to "pending"Rule Priority and Execution
Rules execute in priority order (lowest number first). Understanding execution order is critical:
Stop-on-Match vs Continue
- Stop Processing action: When this action fires, no further rules are evaluated
- Without Stop Processing: All matching rules will execute in order
Example Priority Setup
| Priority | Rule Name | Conditions | Actions |
|---|---|---|---|
| 1 | Reject Bots | honeypot is not empty | Reject |
| 2 | Reject Disposable | email in disposable list | Reject |
| 3 | Set Defaults | source is empty | Set source |
| 4 | Route MBA | program contains “MBA” | Set program |
| 5 | Route Nursing | program contains “Nursing” | Set program |
Tip: Place rejection rules at the top (low priority numbers) so invalid leads are filtered before enrichment runs.
Lookup Tables
Lookup tables allow you to map values from one field to another using a reference table.
Creating a Lookup Table
- Go to Settings → Lookup Tables
- Click Add Table
- Enter a name (e.g., “zip_to_state”)
- Add key-value pairs or upload a CSV
Example: Zip Code to State
| Key (zip_code) | Value (state) |
|---|---|
| 90210 | California |
| 10001 | New York |
| 75001 | Texas |
Using in Rules
Action: Lookup "state" from table "zip_to_state" using field "zip_code"Transformations
Transform field values using built-in functions:
| Transformation | Input | Output |
|---|---|---|
uppercase | ”john doe" | "JOHN DOE” |
lowercase | ”John DOE" | "john doe” |
titlecase | ”john doe" | "John Doe” |
trim | ” john " | "john” |
phone_format | ”(555) 123-4567" | "+15551234567” |
email_domain | ”[email protected]" | "school.edu” |
first_word | ”John Doe" | "John” |
last_word | ”John Doe" | "Doe” |
Applying Transformations
Action: Transform field "email" using "lowercase"
Action: Transform field "phone" using "phone_format"
Action: Transform field "first_name" using "titlecase"Formulas
Use formulas for calculated values. Available syntax:
String Concatenation
{{first_name}} {{last_name}}Conditional Logic
{{if state == "CA"}}West Coast{{else}}Other{{/if}}Date Functions
{{today}} → 2024-12-25
{{now}} → 2024-12-25T10:30:00Z
{{date_add 30}} → Date 30 days from nowField References
{{field:email}}
{{field:custom_fields.start_date}}Import and Export Rules
Exporting Rules
- Go to Settings → Enrichment Rules
- Click Export Rules
- Download the JSON file
Importing Rules
- Go to Settings → Enrichment Rules
- Click Import Rules
- Upload your JSON file
- Review and confirm the import
Importing rules will add to your existing rules, not replace them. Duplicate rules may be created.
Rule JSON Format
{
"rules": [
{
"name": "Reject Disposable Emails",
"priority": 10,
"enabled": true,
"conditions": {
"operator": "OR",
"rules": [
{ "field": "email", "operator": "ends_with", "value": "@mailinator.com" },
{ "field": "email", "operator": "ends_with", "value": "@tempmail.com" }
]
},
"actions": [
{ "type": "reject", "reason": "Disposable email" }
]
}
]
}Testing Rules
Before going live, test your rules with sample data.
Using the Test Feature
- Go to Settings → Enrichment Rules
- Click Test Rules
- Enter sample lead data (JSON or form)
- Click Run Test
- Review which rules matched and what actions would execute
Example Test
Input:
{
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"state": "CA"
}Output:
Rule 2 "Reject Disposable Emails" MATCHED
→ Action: Reject lead with reason "Disposable email"
→ Processing stoppedBest Practices
-
Order matters - Put rejection rules first, enrichment rules second, routing rules last
-
Test thoroughly - Use the test feature before enabling new rules in production
-
Use descriptive names - “Reject Bot Submissions” is better than “Rule 1”
-
Document complex logic - Add notes to explain why rules exist
-
Start simple - Begin with a few rules and add complexity gradually
-
Monitor rejections - Regularly review rejected leads to ensure rules aren’t too aggressive
-
Use lookup tables - For mappings with many values, use lookup tables instead of many conditions
-
Version control - Export rules regularly as backup
Troubleshooting
Rule Not Firing
- Check that the rule is enabled
- Verify conditions are correct (case sensitivity, exact match vs contains)
- Check priority order - a higher-priority rule may have stopped processing
- Use the Test Rules feature to debug
Unexpected Results
- Review the order of actions within the rule
- Check for conflicting rules with overlapping conditions
- Look at the lead activity log for the processing timeline
Performance Issues
- Reduce the number of regex conditions (they’re slower)
- Use field indexing for frequently-matched fields
- Consider consolidating similar rules
API Reference
Manage enrichment rules programmatically:
| Endpoint | Method | Description |
|---|---|---|
/api/enrichment/rules | GET | List all rules |
/api/enrichment/rules | POST | Create a rule |
/api/enrichment/rules/:id | GET | Get rule details |
/api/enrichment/rules/:id | PATCH | Update a rule |
/api/enrichment/rules/:id | DELETE | Delete a rule |
/api/enrichment/test | POST | Test rules against sample data |
See the API Reference for full documentation.