# Lead and Account Matching

Many Lead routing workflows require that you first attempt to match a Lead to an Account, Contact or other Lead. Gradient Works enables you to easily add these to your Flows with the following actions:

* [Match Lead to Account](https://docs.gradient.works/kb/automation-builder-kit-abk/actions/matching/matchleadtoaccountaction)
* [Match Lead To Contact](https://docs.gradient.works/kb/automation-builder-kit-abk/actions/matching/matchleadtocontactaction)
* [Match Lead To Lead](https://docs.gradient.works/kb/automation-builder-kit-abk/actions/matching/matchleadtoleadaction)

We also have an action to allow you to match Accounts with other Accounts

* [Match Account To Account](https://docs.gradient.works/kb/automation-builder-kit-abk/actions/matching/matchaccounttoaccountaction)

Each action uses the same basic concepts to locate a best match: match criteria, filters and rankings (explained in more detail below). Each action outputs specialized matches which you can use later in your flow for assignment or lead conversion.

### Match Criteria

Match Criteria provide a way to define candidate matches by comparing Lead or Account fields with fields on a candidate (e.g. Account, Contact, other Lead). There are three types of matches:

* Domain - Match any two fields that contain a reference to a web domain. Matches of this type will extract a domain name from an email address, website or URL field. For example, the email address `bob@company.com` would match a URL of `https://www.company.com/something`. This is especially useful when matching the `Email` field of a Lead to the `Website` field of an Account.
* Exact - Match any two fields exactly. This is the most restrictive of the match types as it requires that both fields have the exact same value (e.g. if Lead `Company` is "Example", then Account `Name` must contain exactly "Example" in order to match).
* Fuzzy - Match two text fields that are similar. This is especially useful for finding close name matches with slight variations (e.g. "Company, Inc" and "Company")

Match candidates will be retrieved if they match any one of the specified criteria.

### Filters

Filter conditions limit the candidate matches by ensuring they meet certain criteria. You can use familiar operators like equals, greater than and contains to define filters. Candidates must meet all filter criteria to be included.

Specify condition requirements to indicate how to handle multiple conditions:

* All Conditions are Met (AND) - Every condition must be true to include a potential match
* Any Condition is Met (OR) - A match will be included if any individual condition is true
* Custom Condition Logic is Met - Specify custom conditions such as `1 AND (2 OR 3)` like you would in report filter criteria

### Rankings

Ranking provides a way of determining which match is the best match in the event there are multiple match candidates after filtering. These act as tie breakers. Click and drag using the drag and drop icons to reorder them.

There are two types of rankers:

* Rank by Field Value - Order results based on a field in the matched object. For example if you want to ensure that the most recently active Contact is the best match, you could create a ranker that looks at `LastActivityDate` and specifies `Higher is Better` as the order.
* Rank by Roll-Up Calculation - Order results based on a calculation performed on a related list. For example, you could prioritize Accounts with more Contacts by specifying the `Contacts` related list, `COUNT` rollup function, `Id` field on Contact and `Higher is better` for order.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gradient.works/kb/routing/matching.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
