FeaturesEnrichment Rules

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:

  1. Conditions - When should this rule apply?
  2. Actions - What should happen when conditions are met?
  3. 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 TypeDescriptionExample
Field EqualsExact matchstate = "California"
Field ContainsPartial matchemail contains "@edu"
Field Starts WithPrefix matchphone starts with "+1"
Field Ends WithSuffix matchemail ends with ".edu"
Field Is EmptyNo valuecompany is empty
Field Is Not EmptyHas any valuephone is not empty
Field Greater ThanNumeric comparisonage > 18
Field Less ThanNumeric comparisonscore < 50
Field In ListOne of many valuesstate in ["CA", "NY", "TX"]
Field Matches RegexPattern matchemail matches ".*@university\.edu"

Actions

Actions define what happens when conditions are met.

Action TypeDescriptionUse Case
Set FieldSet a field to a valueAssign lead source, set defaults
Transform FieldModify existing valueUppercase name, format phone
Calculate FieldCompute from other fieldsFull name from first + last
Reject LeadStop processing, rejectFilter out invalid leads
Flag for ReviewMark for manual reviewSuspicious leads
Trigger WebhookCall external APIThird-party enrichment
Set ProgramAssign to programRoute to correct program
Stop ProcessingSkip remaining rulesFirst-match-wins logic

Creating Enrichment Rules

Go to SettingsEnrichment 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

PriorityRule NameConditionsActions
1Reject Botshoneypot is not emptyReject
2Reject Disposableemail in disposable listReject
3Set Defaultssource is emptySet source
4Route MBAprogram contains “MBA”Set program
5Route Nursingprogram 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

  1. Go to SettingsLookup Tables
  2. Click Add Table
  3. Enter a name (e.g., “zip_to_state”)
  4. Add key-value pairs or upload a CSV

Example: Zip Code to State

Key (zip_code)Value (state)
90210California
10001New York
75001Texas

Using in Rules

Action: Lookup "state" from table "zip_to_state" using field "zip_code"

Transformations

Transform field values using built-in functions:

TransformationInputOutput
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 now

Field References

{{field:email}}
{{field:custom_fields.start_date}}

Import and Export Rules

Exporting Rules

  1. Go to SettingsEnrichment Rules
  2. Click Export Rules
  3. Download the JSON file

Importing Rules

  1. Go to SettingsEnrichment Rules
  2. Click Import Rules
  3. Upload your JSON file
  4. 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

  1. Go to SettingsEnrichment Rules
  2. Click Test Rules
  3. Enter sample lead data (JSON or form)
  4. Click Run Test
  5. 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 stopped

Best Practices

  1. Order matters - Put rejection rules first, enrichment rules second, routing rules last

  2. Test thoroughly - Use the test feature before enabling new rules in production

  3. Use descriptive names - “Reject Bot Submissions” is better than “Rule 1”

  4. Document complex logic - Add notes to explain why rules exist

  5. Start simple - Begin with a few rules and add complexity gradually

  6. Monitor rejections - Regularly review rejected leads to ensure rules aren’t too aggressive

  7. Use lookup tables - For mappings with many values, use lookup tables instead of many conditions

  8. 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:

EndpointMethodDescription
/api/enrichment/rulesGETList all rules
/api/enrichment/rulesPOSTCreate a rule
/api/enrichment/rules/:idGETGet rule details
/api/enrichment/rules/:idPATCHUpdate a rule
/api/enrichment/rules/:idDELETEDelete a rule
/api/enrichment/testPOSTTest rules against sample data

See the API Reference for full documentation.