From Ryan Mercer: A better way to Check for Duplicate Records in Flow
You probably have Duplicate Rules configured in your Salesforce org, right? Well, if you don’t, you should check them out!
A duplicate rule defines what happens when a user views a record with duplicates or starts creating a duplicate record. Salesforce provides standard duplicate rules for business and person accounts, contacts, and leads. You can also create duplicate rules.
Duplicate rules can bring your Flow to a screeching halt if you try to create a record that already exists. Your duplicate rule is working exactly as designed; your flow, however, is not.

Introducing “Duplicate Record Check”
Duplicate Record Check is an Apex Invocable Action that will allow you to run your duplicate rules on records prior to creating them in your Flow. Take a look at this video introduction for an explanation as to why and how you might use this action.
How to Configure the Component
You can either pass in a single record, a collection of records, or both into the action. If using both, the single record and collection of records MUST be of the same object type!

The action will return two Apex-Defined variables of the Duplicate class:

And each variable, will include:
- Whether a duplicate was found;
- The duplicate record’s Id; and
- The duplicate record’s Object name.

Apex Developer Support
Don’t write Apex? Feel free to skip over this!
This component is supported by the Datacloud Namespace. The shape of the Datacloud results object is a little unwieldy. You can use the DuplicateRecordCheck_Util class to make your life a little easier. Here’s how you use it:
// Assuming your Duplicate Rules are configured accordingly.
Lead ld = new Lead(
FirstName = 'Ryan',
LastName = 'Mercer',
Email = 'ryangmercer@gmail.com'
Company = 'unofficialsf'
);
insert ld;
sObject input = ld.clone(false,true);
List<Duplicate> duplicates = DuplicateRecordCheck_Util.findDuplicates(new List<sObject>{input});
system.assert(duplicates[0].isDuplicate == TRUE);
system.assert(duplicates[0].duplicateRecordId == ld.Id);
system.assert(duplicates[0].duplicatesObjectType == 'Lead');
Installation
Production or Developer Version 1.0
Sandbox Version 1.0