Marketing Automation Best Practices

Automate lead routing to win more deals: lead-to-account matching

The key driver of B2B conversion comes down to speed, in particular lead response time. Lead response time refers to the time it takes to follow up with a lead that has contacted a business. Conversion rates are 8x higher within a response time of 5 minutes vs 6+ minutes, according to a study by XANT. Still, less than 1% of response attempts occur within 5 minutes, whereas 57% of attempts wait longer than a week. Within that time, potential buyers have had the time to move onto day-to-day responsibilities, or worse, your competitor's website.

Lead routing is the process of distributing leads across a sales team, routing them to the right person based on defined lead assignment criteria. With automated, accurate and effective lead routing, lead response times can be decreased and conversion rates increased – resulting in higher sales numbers.

In Salesforce, leads can be routed to queues or specific users based on various criteria, such as geography, industry, potential deal size, or other factors. In this article we will describe a customized account-based routing solution that assigns leads from a company, that match an existing Account to that Account’s owner.

In this article we will describe how to:

Part 1: Automatically assign new leads that match an existing Account, to the Account Owner of that Account

Part 2: Build a solution step-by-step using Salesforce Flow Builder and Process Builder

Part 1: Automatically assign new leads that match an existing Account, to the Account Owner of that Account

Business use case

In this scenario, there is a business need to update the current lead routing process. Currently, leads are being routed to a queue with sales team members that take ownership of leads on an ad-hoc basis. The team cannot dedicate time to visit the lead queue on a regular basis. This means that the majority of leads have a long response time, leading to lost sales opportunities.

There is now a need to update the lead routing process in a way so that leads that already have an Account in Salesforce are routed to that Account’s owner. This way, the Account Owner can quickly pick up that lead, and he or she also already has a good understanding of the lead’s business. 

Requirements and technical solution overview

In this scenario, the match will be based on a match between:

  1. The Lead’s Email Domain and the Account’s related Contact’s Email Domain, OR
  2. The Lead’s Email Domain and the Account’s Website Domain, OR
  3. The Lead’s Company and the Account’s Name

What the final product looks like after implementation

If the Lead matches an existing Account in Salesforce, it will be assigned to that Account’s Account Owner. The match is based on three different criteria/scenarios:

Scenario 1: The Lead’s Email Domain and the Account’s related Contact’s Email Domain match

Scenario 2: The Lead’s Email Domain and the Account’s Website Domain match

Scenario 3: The Lead’s Company and the Account’s Name match

The lead owner receives an email notification about the lead assignment:

Part 2: Build a solution step-by-step using Salesforce Flow Builder

Lead routing in Salesforce can be configured in Salesforce’s Lead Assignment Rules. However, the Lead Assignment Rules in Salesforce do not support the requirements for this specific business use case. Therefore, we have built a customized solution using Flow Builder and Process Builder.

This solution is built on the assumption that no duplicate Accounts exist. If duplicate Accounts exist (based on match of Name, Email Domain or Website Domain), the routing will be based on the first Account that is found based on the set criteria.


Step 1: Create a Formula field on the Lead Object, called “Email Domain”

  • Formula return type: Text 
  • Formula: SUBSTITUTE(Email, LEFT(Email, FIND("@", Email)), NULL)

Step 2: Create a Checkbox field on the Lead Object, called "Used custom assignment"


Step 3: Create a Text Area field on the Account Object, called “Contact Email”


Step 4: Create a Formula field on the Account Object, called “Website Domain”

  • Formula return type: Text 
  • Formula: SUBSTITUTE(Website, LEFT(Website, FIND(".", Website)), NULL)

Step 5: Create a Formula field on the Account Object, called “Email Domain”

  • Formula return type: Text 
  • Formula: SUBSTITUTE(Contact_Email__c, LEFT(Contact_Email__c, FIND("@", Contact_Email__c)), NULL)

Step 6: Create a Flow called "Populate Contact's Email Address on related Account" that populates the field "Contact Email" on the Account Object

6.1. Create a record-triggered Flow


6.2. Configure the trigger and choose the Object in the ‘Start’ Element

  • Trigger the Flow When: A record is created
  • Optimize the Flow for: Actions and Related Records
  • Object: Contact
  • Condition Requirements: Email is not Null


6.3. Drag a ‘Decision’ Element to the canvas with the following configurations, and then drag a connection from the ‘Start’ Element to the ‘Decision’ Element:


  • Label: Is related Account's Contact Email field empty?
  • Description: Checks if the Contact’s related Account’s field “Contact Email” is populated or not
  • Outcome order 1 Label: Yes
  • Condition Requirements to Execute Outcome: All Conditions are met (AND)
  • Resource, Condition & Value: {!$Record.Account.Contact_Email__c}, Is Null, True
  • Outcome order 2 Label: No


6.5. Drag an ‘Update’ Element to the canvas with the following configurations, and then drag a connection from the ‘Decision’ Element to the ‘Update’ Element with Outcome = “Yes”:

  • Label: Update Account’s Contact Email
  • Description: Updates the Account’s Contact Email to its related Contact’s Email
  • Object: Account
  • Condition Requirements to Update Record: All Conditions Are Met (AND) where Id Equals {!$Record.AccountId}
  • Field values for the Account record: Contact_Email__c  <-- {!$Record.Email}


6.7. Save the Flow and name it ‘Populate Contact's Email Address on related Account’ and activate the Flow

Step 7: Create a Process Builder called "Account: Format website field upon creation" that formats the field "Website" on the Account Object upon creation

7.1. Create a new Process Builder 

  • Name: Account: Format website field upon creation
  • The process starts when: A record changes


7.2. Choose Object and Specify When to Start the Process

  • Object: Account
  • Start the process: only when a record is created 


7.3. Define Criteria

  • Criteria Name: Website is populated?
  • Criteria for Executing Actions: Conditions are met
  • Conditions: [Account].Website Is Null Boolean False


7.3. Set Immediate Action


  • Action Type: Update Records
  • Action Name: Format Website field
  • Record Type: Select the Account record that started your process
  • Criteria for Updating Records: No criteria—just update the records!
  • Set new field values for the records you update
  • Field: Website
  • Type: Formula
  • Value:

IF(CONTAINS([Account].Website,"https://www"),

     SUBSTITUTE([Account].Website,"https://www","www"),

 

   IF(CONTAINS([Account].Website,"http://www"),

        SUBSTITUTE([Account].Website,"http://www","www"),

 

      IF(CONTAINS([Account].Website,"https://"),

           SUBSTITUTE([Account].Website,"https://","www."),

 

           IF( CONTAINS([Account].Website,"http://"),

               SUBSTITUTE([Account].Website,"http://","www."),

 

               IF(NOT(CONTAINS([Account].Website,"www")),

                  "www."+[Account].Website,

                   [Account].Website

               )

           )

      )

   )

)


7.5. Activate the Process Builder


Step 8: Create a Process Builder called "Account: Format website field upon update" that formats the field "Website" on the Account Object upon update

8.1. Create a new Process Builder 

  • Name: Account: Format website field upon update
  • The process starts when: A record changes


8.2. Choose Object and Specify When to Start the Process

  • Object: Account
  • Start the process: when a record is created or edited


8.3. Define Criteria

  • Criteria Name: Website is populated?
  • Criteria for Executing Actions: Conditions are met
  • Conditions: [Account].Website Is Null Boolean False AND [Account].Website Is Changed Boolean True

8.4. Set Immediate Action


  • Action Type: Update Records
  • Action Name: Format Website field
  • Record Type: Select the Account record that started your process
  • Criteria for Updating Records: No criteria—just update the records!
  • Set new field values for the records you update
  • Field: Website
  • Type: Formula
  • Value:

IF(CONTAINS([Account].Website,"https://www"),

     SUBSTITUTE([Account].Website,"https://www","www"),

 

   IF(CONTAINS([Account].Website,"http://www"),

        SUBSTITUTE([Account].Website,"http://www","www"),

 

      IF(CONTAINS([Account].Website,"https://"),

           SUBSTITUTE([Account].Website,"https://","www."),

 

           IF( CONTAINS([Account].Website,"http://"),

               SUBSTITUTE([Account].Website,"http://","www."),

 

               IF(NOT(CONTAINS([Account].Website,"www")),

                  "www."+[Account].Website,

                   [Account].Website

               )

           )

      )

   )

)


8.5. Activate the Process Builder


Step 9: Create a Flow called "Assign Leads to existing Account Owner"

9.1. Create a record-triggered Flow

9.2. Configure the trigger and choose the Object in the ‘Start’ Element

  • Trigger the Flow When: A record is created
  • Run the Flow: After the record is saved
  • Object: Lead
  • Condition Requirements: None (or to be adjusted depending on your needs)


9.3. Drag a ‘Get Records’ Element to the canvas with the following configurations, and then drag a connection from the ‘Start’ Element to the ‘Get Records’ Element

  • Label: Get Account
  • Description: Get Account that matches Lead details, with match based on Website Domain, Email Domain or Name/Company
  • Condition Requirements: Any Condition Is Met (OR)
  • Condition 1: Contact_Email__c Equals {!$Record.Email_Domain__c}
  • Condition 2: Website_Domain__c Equals {!$Record.Email_Domain__c}
  • Condition 3: Name Contains {!$Record.Company}


9.4. Drag a ‘Decision’ Element to the canvas with the following configurations, and then drag a connection from the ‘Get Records’ Element to the ‘Decision’ Element:

  • Label: Did any Account match the Lead?
  • Description: Checks if any Account was found that matches the Lead
  • Outcome order 1 Label: Yes
  • Condition Requirements to Execute Outcome: All Conditions are met (AND)
  • Resource, Condition & Value: {!Get_Account}, Is Null, False
  • Outcome order 2 Label: No


9.5. Drag an ‘Update’ Element to the canvas with the following configurations, and then drag a connection from the ‘Decision’ Element to the ‘Update’ Element with Outcome = “Yes”:

  • Label: Update Lead Owner
  • Description: Updates Lead Owner to same as matching Account's Account Owner
  • Object: Lead
  • Condition Requirements to Update Record: None - Always update record 
  • Field values for the Account record: 
  • OwnerId <-- {!Get_Account.OwnerId}
  • Used_custom_assignment__c <-- True


9.6. Drag an ‘Action’ Element to the canvas with the following configurations, and then drag a connection from the ‘Update’ Element to the ‘Action’ Element:

  • Action: Choose an email alert for new lead assignment
  • Label: Send new lead assignment notification
  • Description:  Sends an email alert to the Lead Owner
  • Record ID: {!$Record.Id}


9.7. Save the Flow and name it ‘Assign Leads to existing Account Owner’ and activate the Flow

Step 10: Create a report called "Leads assigned using custom assignment" with the report type Leads with converted lead information



The checkbox “Used custom assignment” will be set to true if the Lead has used the lead assignment process described and implemented in this guide. It’s a good way to measure how well the process is working and to identify data gaps.

Considerations

  • The criteria for triggering the Flows and the Process Builder can and should most likely be customized to your organization. For example, you might only want to assign Leads according to this setup for certain types of Leads, such as depending on the Lead’s Country or Priority etc.
  • When creating records in bulk (with for example Data Loader) that are associated with the same record, 12 is the maximum number of records that can be created in bulk with this setup – otherwise the Flow running will only create the first 12 records. An example of this is creating Contacts in bulk that are to be associated with the same Account. Two possible workarounds are described by Salesforce here.
  • Avoid updating the same record more than 12 times in the same bulk operation if you have a flow with a wait step triggered by those updates.
  • Add more criteria so you are only really updating a record when necessary, see Avoid unwanted Actions in Process for more info.

For the first recommendation, you can for example change the Batch Size in the Settings for Data Loader to 12.

  • Migration activities should be performed for existing records for the new fields created, so that they contain a value (excluding formula fields)
  • The Flow “Populate Contact's Email Address on related Account” is built on the assumption that all Accounts must be associated with at least one Contact, and that the Contact’s Email Adress is a mandatory field. If this is not the case for your organization, the Flow must be tweaked accordingly to also run on Update, and not just on Create (i.e. when an existing Contact’s Account is changed)

Learn more about Salesforce solutions that can help you automate sales and marketing processes, become more efficient, and get the most out of your CRM:

LEARN MORE

Related Articles

Discover the latest product updates, announcements, and articles from the Exelement team

Some of our clients

Get in touch with our team.

Please describe your integration needs as in much detail as possible, our team will be in touch with you as soon as possible to arrange a free consultation to discuss your project.
Gamla Brogatan 32, Stockholm