# Attributes & Attribute Matcher

### What are Attributes?

Attributes are custom fields you can attach to your **users** and **leads**. They extend the standard profile information SalesChat already tracks — letting you store details like sales process, campaign source, lead stage, disposition, or location.

Attributes are typically set via integrations and APIs (e.g., synced from your CRM). Once set, they become available throughout SalesChat — including in the Attribute Matcher, where you can build rules based on them.

***

### What is an Attribute Matcher?

An Attribute Matcher is a rule engine that lets you control platform behaviour based on user and lead attributes. You define conditions, and SalesChat evaluates them in real time to decide whether a feature should be enabled or restricted for a given user or lead.

**Example use case:** **Contact Free Flow** — controlling which users are allowed to send freeflow (non-templated) messages to leads. You might want only users assigned to a specific sales process or campaign to have this ability.

***

### Scope (Entity Types)

A matcher can evaluate attributes from two entity types:

* **User** — the SalesChat user (agent/rep). Built-in properties: email, name. Custom attributes: any attributes set on the user (e.g., process, location, team).
* **Lead** — the contact/lead being communicated with. Built-in properties: phone number, first name, last name, CRM ID. Custom attributes: any attributes set on the lead (e.g., stage, disposition, campaign).

You can scope a matcher to **User only**, **Lead only**, or **both**. The scope determines which properties are available when building conditions.

***

### Properties

Properties are the fields you can evaluate in a condition. They come in two categories:

#### Built-in properties

These are always available:

<table><thead><tr><th>Property</th><th>Entity Type</th><th width="282.42578125">Description</th></tr></thead><tbody><tr><td>Email</td><td>User</td><td>Agent's email address</td></tr><tr><td>Name</td><td>User</td><td>Agent's display name</td></tr><tr><td>Team (to be introduced soon)</td><td>User</td><td>Agent's from the selected team</td></tr><tr><td>Phone Number</td><td>Lead</td><td>Lead's phone number</td></tr><tr><td>First Name</td><td>Lead</td><td>Lead's first name</td></tr><tr><td>Last Name</td><td>Lead</td><td>Lead's last name</td></tr><tr><td>CRM ID</td><td>Lead</td><td>Lead's CRM identifier</td></tr></tbody></table>

#### Custom attributes

Any attributes that have been set on users or leads in your organization appear automatically in the property dropdown. For example, if your CRM sync sets a `process` attribute on users, it will show up as a selectable property.

If the attribute you need isn't listed yet, you can manually add it by clicking **Add custom attribute** at the bottom of the property dropdown, selecting the entity type (User or Lead), and typing the attribute key.

***

### Conditions and Condition Sets

#### Conditions

A condition is a single check: **property** + **operator** + **value**.

For example: *user's process* **equals** *"outbound"*

#### Condition Sets (AND + OR logic)

Conditions are grouped into **Condition Sets**:

* Within a set, **all conditions must be true** (AND logic)
* Across sets, **any one set matching is enough** (OR logic)

```
Matcher passes if:
   (Set 1: ALL conditions true)    ← AND within
   OR                              ← OR across
   (Set 2: ALL conditions true)
   OR ...
```

**Example:** Allow freeflow messaging if the user is in the "outbound" process AND located in "Mumbai", OR if the lead's campaign is "re-engagement".

***

### Operator Reference

Operators define how a property's value is compared. Below is how each operator evaluates:

#### Text matching

| Operator            | Evaluation                                                                | Value input                       | Example                                                                         |
| ------------------- | ------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------- |
| **equals**          | Passes if the actual value matches **any one** of the specified values    | One or more values (multi-select) | Process equals "outbound" or "inbound" — passes if the user's process is either |
| **not equals**      | Passes if the actual value does **not** match any of the specified values | One or more values (multi-select) | Disposition not equals "DND", "invalid" — passes only if disposition is neither |
| **contains**        | Passes if the actual value contains the specified text as a substring     | Single value                      | Email contains "@saleschat" — passes for "<john@saleschat.pro>"                 |
| **doesn't contain** | Passes if the actual value does **not** contain the specified text        | Single value                      | Name doesn't contain "test" — filters out test accounts                         |

#### Numeric comparison

| Operator         | Evaluation                                                                | Value input   | Example                              |
| ---------------- | ------------------------------------------------------------------------- | ------------- | ------------------------------------ |
| **greater than** | Passes if the numeric value is strictly greater than the specified number | Single number | Lead score greater than 50           |
| **less than**    | Passes if the numeric value is strictly less than the specified number    | Single number | Days since last contact less than 30 |

> Non-numeric values are treated as 0 during numeric comparison.

#### Presence checks

| Operator       | Evaluation                                         | Value input   | Example                                                    |
| -------------- | -------------------------------------------------- | ------------- | ---------------------------------------------------------- |
| **is set**     | Passes if the attribute exists and has any value   | None required | Phone number is set — ensures lead has a phone number      |
| **is not set** | Passes if the attribute is missing or has no value | None required | CRM ID is not set — identifies leads not yet synced to CRM |

#### Pattern matching

| Operator          | Evaluation                                                             | Value input          | Example                                                |
| ----------------- | ---------------------------------------------------------------------- | -------------------- | ------------------------------------------------------ |
| **matches regex** | Passes if the actual value matches the full regular expression pattern | Single regex pattern | Phone matches `^\+91.*` — matches Indian phone numbers |

> The regex must match the **entire** value, not just a part of it. Invalid regex patterns will not match.

***

### Example: Allow Contact Freeflow Chat for a lead in Org

**Scenario:** You want to allow freeflow messaging for users working on outbound sales in specific locations, or for any user contacting high-priority leads.

**Condition Set 1** — Outbound users in target locations

| Property                  | Operator | Value                    |
| ------------------------- | -------- | ------------------------ |
| Process (user attribute)  | equals   | outbound                 |
| Location (user attribute) | equals   | Mumbai, Delhi, Bangalore |

**Condition Set 2** — High-priority leads

| Property                  | Operator | Value            |
| ------------------------- | -------- | ---------------- |
| Stage (lead attribute)    | equals   | hot, negotiation |
| Campaign (lead attribute) | is set   | —                |

**Result:** A user can send freeflow messages if they are an outbound user in one of the target cities, **or** if the lead is in a high-priority stage and has a campaign assigned.
