# Creating Evaluation Rules

> Source: https://docs.trailspark.ai/docs/evaluation-rules

## Overview

Evaluation rules filter which leads are included or excluded from scoring based on CRM and product data. Rules are checked before the AI scores each lead. If a lead fails a rule condition, it is excluded from evaluation.

## Accessing Rules

Navigate to **Rules** from the main navigation. The page heading is **Integration Rules**. Each connected integration appears as a collapsible card showing its current rule count.

## Supported Integrations

Rules can be created for any connected integration:

| Integration | Available Objects |
|-------------|-------------------|
| **Salesforce** | Lead, Contact, Account |
| **HubSpot** | Contact, Company |
| **Product Org** | Flat fields with dot notation (no object tabs) |

> [!NOTE]
> Only connected integrations appear. Product Org rules appear when your organization has product workspace data from webhooks.

## Creating Rules

### Add a Configuration

1. Click **Add Configuration**
2. Select the integration from the dialog
3. The integration card expands and enters edit mode

### Build Rule Conditions

Each rule has four components:

| Component | Description |
|-----------|-------------|
| **Object Type** | The CRM object to query (e.g., Lead, Contact, Account) |
| **Field** | The specific field on that object |
| **Operator** | How to compare the value |
| **Value** | The expected value |


### Available Operators

Operators shown in the dropdown depend on the selected field's type.

| Operator | Field Types |
|----------|-----------|
| Equals / Not Equals | String, picklist, boolean, enumeration, date/datetime |
| Contains / Not Contains | String |
| Starts With / Ends With | String |
| Greater Than / Less Than | String, number, currency, percent, date/datetime |
| Greater Than or Equal / Less Than or Equal | String, number, currency, percent, date/datetime |
| Is Empty / Is Not Empty | String, number, currency, percent, date/datetime, enumeration |
| Is True / Is False | Boolean |

Field metadata is loaded from your CRM automatically. For picklist/enumeration fields, available values are shown in the value selector.

### Allow If Empty

Each rule has an **Allow If Empty** toggle. When enabled, leads where the field has no value will still pass the rule (rather than being excluded).

### Save Rules

Click **Save** to apply. Rules become active immediately for all future evaluations.

## Rule Examples

**Exclude opted-out leads (Salesforce):**
- Object: Lead | Field: HasOptedOutOfEmail | Operator: Is False

**Only score marketing qualified leads (Salesforce):**
- Object: Lead | Field: Status | Operator: Equals | Value: Marketing Qualified Lead

**Filter by account revenue (Salesforce):**
- Object: Account | Field: AnnualRevenue | Operator: Greater Than | Value: 1000000

**Exclude do-not-call contacts (HubSpot):**
- Object: Contact | Field: hs_do_not_call | Operator: Is False

**Filter by product plan (Product Org):**
- Field: planName | Operator: Equals | Value: Enterprise

Product Org rules are flat (no object type tabs). Use dot notation for nested fields, e.g., `customFields.projects_count` or `featureFlags.api_enabled`.

## Multiple Rules

You can define multiple rules per integration. All rules within an integration are evaluated together -- a lead must satisfy all conditions to be included in scoring.

Rules across different integrations are independent. You might have Salesforce rules filtering by lead status and Product Org rules filtering by product plan.

## Managing Rules

### Edit Existing Rules

1. Expand the integration card
2. Click **Edit** to enter edit mode
3. Modify, add, or remove rule conditions
4. Click **Save**

### Delete Rules

- **Single integration**: Remove all rules for that integration by clearing all conditions and saving
- **All rules**: Click **Delete All** to remove rules for all integrations

> [!WARNING]
> Deleting rules is permanent and takes effect immediately.

## How Rules Affect Evaluation

During evaluation, TrailSpark checks each lead's cached integration data against the configured rules. Leads that fail any rule condition are excluded from AI scoring entirely -- they will not receive a score or appear in evaluation results.

Rules use AND logic within each integration: a lead must satisfy all conditions for that integration to pass. Rules across different integrations are evaluated independently.

Field metadata (the list of fields available in dropdowns) is cached and refreshed periodically.

## Next Steps

- [Destinations Overview](/docs/destinations-overview) -- Configure where scores are sent
- [ICP Overview](/docs/icp-overview) -- Define your ideal customer profile