> ## Documentation Index
> Fetch the complete documentation index at: https://docs.os.default.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Account-based lead routing: sending leads to the account owner with Default

> How to route new leads and contacts from accounts you already work to the account owner with Default: a CRM Record Created or Form Submission trigger starts the workflow, Match Record finds the Salesforce Account or HubSpot Company by company domain, Update Record or a Rules of Engagement rule assigns the account owner, and Round-Robin or territory rules route everyone else.

Account-based routing sends a new lead or contact from a company you already work to the rep who
owns that company's account, so 1 rep works each account. People from companies you don't work
yet go to a queue as usual.

Default runs account-based routing as a workflow for Salesforce and HubSpot. A **Match Record** node
finds the person's Salesforce Account or HubSpot Company by company domain, the **Match** branch
assigns the account owner, and the **No Match** branch sends everyone else to a **Round-Robin**
queue or to [Rules of Engagement](/rules-of-engagement) territories.

## Account-based routing at a glance

| Step | Node | What it does |
| - | - | - |
| 1. Start | **CRM Record Created** or **Form Submission** | Starts a run for each new lead, contact, or form fill. |
| 2. Find the account | **Match Record** on the Account or Company | Compares the account's website or domain with the domain of the person's email. |
| 3. Matched people | **Update Record**, or a **Rules of Engagement** rule | Writes the account owner as the person's owner. Optionally **Convert Lead** merges a Salesforce Lead into the Account. |
| 4. Everyone else | **Round-Robin**, or **Rules of Engagement** | Picks a rep from a queue, or from the queue for the person's territory. |
| 5. Check | **Runs** | Shows which account matched and which owner was written. |

## Setup for account-based routing

| Requirement | Where | Why |
| - | - | - |
| Salesforce or HubSpot connected | **Settings** → **Integrations**. See [Salesforce](/settings/integrations/salesforce) and [HubSpot](/settings/integrations/hubspot). | **Match Record** reads accounts, and **Update Record** writes the owner. |
| A domain on each account | The Account **Website** in Salesforce, or the Company **Company Domain Name** in HubSpot | Matching compares this value with the person's email domain. An account without it never matches. |
| A queue with a routing policy | **Routing** → **Queues** and **Policies**. See [Queues](/queues) and [Policies](/policies). | **Round-Robin** picks the rep for people without an account. Include **Objects** in the policy's **Assignment Units**. |
| Reps mapped to their CRM user | **Settings** → **Users**. See [Users](/settings/users). | Default needs the mapping to write a queue pick as the owner, to check queue membership, and to run owner rules in Rules of Engagement. |
| Optional: a Rules of Engagement ruleset | **Routing** → **Rules of Engagement**. See [Rules of Engagement](/rules-of-engagement). | Handles territories and owners who have left. |

## 2 ways to give matched people to the account owner

| | Copy the owner with **Update Record** | Route with a **Rules of Engagement** rule |
| - | - | - |
| How it works | Sets the person's owner field to the account's owner field from **Match Record**. | A rule's **Route to** is **User**, set to the account's owner field, and **Update Record** writes **Latest resolved user**. |
| Owner mapping in Default | Not needed. Default writes the CRM user ID as it is. | Needed. An unmapped owner counts as empty. |
| Owner who left | Default does not check, so the person goes to that owner unless **Match Details** filters the account out. | The rule's **Fallback** applies, for example a queue. |
| Account without an owner | Salesforce Accounts always have one. A HubSpot Company may not, and **Update Record** then has nothing to write and fails. | The rule does not match, and the rules below it decide. |
| Where the decision is logged | The workflow's **Runs** | **Runs** and the ruleset's **Logs** tab |

Neither path counts toward a queue's round robin, because no queue picked the owner. A rule's
**Fallback** queue pick does count, once **Update Record** writes it.

The steps below use **Update Record**. For the Rules of Engagement version, see
[Route with Rules of Engagement instead](#route-with-rules-of-engagement-instead).

## Build an account-based routing workflow for Salesforce

This example sends each new inbound Salesforce Lead to the owner of its company's Account. Leads
from companies without an Account go to the next member of a queue named `Inbound Leads`.

<Steps>
  <Step title="Add the trigger">
    In **Workflows**, create a workflow and add the **CRM Record Created** trigger. Set **CRM** to
    **Salesforce** and **Record** to **Lead**. Optionally, add a **Condition**, for example
    `Lead Source` is `Inbound`.
  </Step>

  <Step title="Match the Account by company domain">
    Select **Add Node** and add **Match Record** from the **Records** section. Set **CRM** to
    **Salesforce** and **Record** to **Account**. Under **Match Details**, select **Edit**, choose
    **Website** and **domain matches**, pick the Lead's **Email** from the trigger, and choose
    **Domain from email**. Select **Save changes**. Personal email domains such as `gmail.com` never
    match. See [Match an account by company domain](/workflows/steps-crm#match-an-account-by-company-domain).
  </Step>

  <Step title="Keep only accounts owned by a current rep">
    In **Match Details**, add a second condition joined with **and**: **Owner ID** **equals**
    **Queue:** `Account Executives`, a queue that holds every rep who owns accounts. Accounts owned
    by anyone else, such as an integration user or a rep who left, take **No Match** and go to the
    round robin.
  </Step>

  <Step title="Pick 1 Account when several match">
    Under **Prioritize matched records by**, select **Add tiebreaker** and choose
    **Largest by employees**. Add **Most recently modified** below it. See
    [When several Salesforce accounts match](/lead-routing/matching/salesforce-lead-to-account#when-several-salesforce-accounts-match).
  </Step>

  <Step title="Send matched leads to the account owner">
    On the **Match** branch, add **Update Record**. Set **Platform** to **Salesforce**,
    **Record Type** to **Lead**, and **Record to update** to the Lead's record ID from the trigger.
    Under **Fields**, add **Owner ID** and choose the Account's **Owner ID** from the
    **Match Record** step. To alert the owner too, add **Send Slack Message** with that **Owner ID**
    under **Recipients**. The owner needs a Salesforce and a Slack mapping in **Settings** → **Users**.
  </Step>

  <Step title="Round-robin everyone else">
    On the **No Match** branch, add **Round-Robin** with **Queue** set to `Inbound Leads`. Then add
    **Update Record** for the Lead and set **Owner ID** to **Latest assigned user** under
    **Round robin**. To split by region or size instead, see
    [Territory and segment routing](/lead-routing/territories).
  </Step>

  <Step title="Test and publish">
    Select **Test**, choose the trigger, and fill in a test Lead whose email domain belongs to an
    existing Account. Select **Run Test** and check the Lead owner in Salesforce. Then select
    **Publish** and check that the status next to the
    [deployment switch](/workflows#the-deployment-switch) reads **Live**. A new workflow goes live
    when you first publish it. If the status reads **Paused**, turn the switch on.
  </Step>
</Steps>

<Warning>
  A workflow test performs real actions in Salesforce. It changes the Lead owner and counts queue
  assignments. Use a test Lead.
</Warning>

A **Queue:** condition counts only active members with a CRM mapping. A member paused with
**Pause assignments** counts as outside the queue, so their accounts' leads take **No Match** while
they are paused. To avoid that, use [Rules of Engagement](#route-with-rules-of-engagement-instead).

### Merge matched leads into the Account

To turn a matched Lead into a Contact on the existing Account, add **Convert Lead** after
**Update Record** on the **Match** branch. Set **Lead to convert** to the Lead's record ID and
**Account to merge into (optional)** to the Account's ID from the **Match Record** step. Leave
**Owner (Optional)** empty: Default then sends no owner, and Salesforce gives the new Contact the
Lead's owner, which is now the account owner. Conversion is permanent and needs the **Author Apex**
permission. See
[Convert a matched lead into the existing account](/lead-routing/matching/salesforce-lead-to-account#convert-a-matched-lead-into-the-existing-account).

### Route form fills to the account owner

A **Form Submission** workflow starts from form data, so it checks for the person before the
account:

1. Add **Match Record** for a Contact, then a Lead, by email. People who already exist keep their
   owner. See [Salesforce contact matching](/lead-routing/matching/salesforce-contacts).
2. On the last **No Match**, add the Account **Match Record** from the steps above.
3. On its **Match** branch, add **Create Record** for the Lead with **Owner ID** set to the
   Account's **Owner ID**. On **No Match**, add **Round-Robin**, then **Create Record** with
   **Owner ID** set to **Latest assigned user**.
4. To let the person book with the account owner, add **Display Scheduler**, turn off
   **Use event hosts**, and add the Account's **Owner ID** as the host. The owner needs a
   Salesforce mapping in **Settings** → **Users** so Default can find their calendar. See
   [Connect a scheduler to your form](/forms/scheduler).

## Route with Rules of Engagement instead

A [Rules of Engagement](/rules-of-engagement) ruleset puts the account owner and your territories
in 1 ordered list:

1. On the ruleset page, select **Add source** and add the Salesforce Account or the HubSpot
   Company. Its fields become available in rule conditions and as **User** targets, and the fields
   your rules use are saved automatically.
2. Select **New rule** and name it `Existing account owner`. Under **Criteria**, check that the
   account's owner field **is not NULL**. Set **Route to** to **User** with the owner field, and
   set **Fallback** to a queue such as `Named Accounts`. Select **Save changes**.
3. Keep it above your territory rules. **New rule** adds a rule at the bottom, so drag it to the
   top of an existing ruleset. Then select **Publish**.
4. In the workflow, add a **Rules of Engagement** node with this ruleset on both branches of the
   Account **Match Record**. On **No Match** the owner input is empty, so the territory rules
   decide.
5. On **Resolved**, add **Update Record** with the owner field set to **Latest resolved user**. On
   **Else**, add **Round-Robin** for a catch-all queue, then **Update Record** with the owner field
   set to **Latest assigned user**. If a queue in the ruleset can end up with no active members,
   check that **Latest resolved user** exists with a **Multi-Branch** first.

See [Route named accounts to their existing owner](/lead-routing/territories#route-named-accounts-to-their-existing-owner)
for a full ruleset with territory rules.

## Route target accounts differently

Default uses the target account fields in your CRM, for example a checkbox or a tier picklist on
the Account or Company. Use the field in 1 of these places:

| Goal | Where to put the condition |
| - | - |
| Only target accounts go to their owner, and other matched leads join the round robin | **Match Details**, joined with **and**, for example your target account checkbox **equals** True. Other accounts take **No Match**. |
| Target accounts get a different action, such as an alert to the owner | A **Multi-Branch** node on the **Match** branch, for example the tier **is any of** `Tier 1`. Connect **Else** to the standard owner write. |
| Target accounts whose owner can't take the lead go to a strategic team | In your ruleset, add a rule below `Existing account owner` whose criteria match the tier, and route it to a **Queue** such as `Strategic Accounts`. Use the same queue as the owner rule's **Fallback**. |

## Salesforce and HubSpot differences

<AccordionGroup>
  <Accordion title="Salesforce">
    * **Record**: **Account**, matched on **Website**. Write the owner to the Lead or Contact
      **Owner ID**.
    * Salesforce requires an owner on every Account, so unowned Accounts usually sit with an
      integration user. The **Queue:** condition in **Match Details** keeps them out.
    * **Convert Lead** can merge a matched Lead into the Account. It works only in Salesforce.
    * Salesforce can refuse to assign a record to a deactivated user, so the owner write can fail
      when an Account still belongs to one. Remove departed reps from the queue, and the
      **Queue:** condition keeps their Accounts out.
  </Accordion>

  <Accordion title="HubSpot">
    * **Record**: **Company**, matched on **Company Domain Name**. Write the owner to the contact's
      **Contact owner** from the Company's **Company owner**.
    * A HubSpot Company can have no owner. Default does not write an empty owner, and an
      **Update Record** with nothing left to write fails. Add **Company owner** **is not NULL** to
      **Match Details**, so Companies without an owner take **No Match**.
    * Link the contact to the matched Company with **Create Association**. When the contact is
      already associated, match with **Match by association** instead. See
      [HubSpot contact-to-company matching](/lead-routing/matching/hubspot-contacts-to-companies).
    * In a form workflow, find or create the contact first. See
      [HubSpot contact matching](/lead-routing/matching/hubspot-contacts).
  </Accordion>
</AccordionGroup>

## Check that account-based routing worked

* **Runs**: open the workflow, select **Runs** at the top, and select a run. The **Match Record**
  step shows its conditions, how many accounts the CRM returned, and the one it chose. The
  **Update Record** step shows the owner it wrote. See [Run logs](/workflows/run-logs).
* **Rules of Engagement**: admins can open the ruleset and select **Logs** to see which rule
  decided and why.
* **Assignments**: in **Routing**, select **Assignments**, then **Object assignments**. Queue
  picks appear here once they are written as the owner. Owners that no queue picked do not.
* **The CRM**: the person's record shows the account owner, and a converted Lead appears as a
  Contact on the Account. For the full trail, see [Why a lead went to a rep](/lead-routing/logs).

## Troubleshoot account-based routing

| What you see | What to check |
| - | - |
| A lead from a known account goes to the round robin | Check the account's **Website** or **Company Domain Name** and the lead's email domain. Personal email addresses never match. If you use a **Queue:** condition, check that the owner is an active, mapped member of that queue. |
| The lead goes to the wrong account's owner | Add or reorder tiebreakers under **Prioritize matched records by**. Without them, the first account the CRM returns wins. |
| **Update Record** fails on the **Match** branch | The account has no owner, or its owner is a deactivated Salesforce user. Add an owner condition to **Match Details**, as in the steps above. |
| Leads go to a rep who left | Add the **Queue:** condition to **Match Details**, or route with a Rules of Engagement rule that has a **Fallback**. |
| The `Existing account owner` rule never matches | Map the owner's CRM user in **Settings** → **Users**, and check that the workflow has the account before the Rules of Engagement node. |
| **Convert Lead** fails | Give the connected Salesforce user the **Author Apex** permission, and review Salesforce duplicate rules. See [Troubleshoot Salesforce lead-to-account matching](/lead-routing/matching/salesforce-lead-to-account#troubleshoot-salesforce-lead-to-account-matching). |

Related: [Lead routing software from Default](https://www.default.com/product/lead-routing-software)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.