FuzzyWuzzy Algorithm with Salesforce Flow

Munawirrahman
3 min readDec 27, 2020

--

FuzzyWuzzy UI

Hi Folks!

In this article, I’d like to show you about my porting result from xdrop’s Java FuzzyWuzzy algorithm (originally from python FuzzyWuzzy)

Why FuzzyWuzzy in Salesforce?
- This package will help you to automate a bunch of boring stuffs related to string processing in Salesforce
- Previously, I used Python FuzzyWuzzy library to process my strings. So to have this function, I needed to expose an API to serve requests from Salesforce and Salesforce will need to callout to that API. But with this, no more callout!
- Currently, Salesforce has similar function which is Contains, but with sometimes, contains is not enough because contains doesn’t care about typos and abbreviation when we’re matching strings. So, you’ll need a new function to achieve this

So, what is FuzzyWuzzy?

FuzzyWuzzy (or Fuzzy Matching) is a method to calculate similarity in percentage between 2 strings. It uses Levenshtein Distance to calculate the similarity.

How to use Fuzzywuzzy in Salesforce Flow?

a. Install this package to your Salesforce org (don’t forget to change login to test.login if you want to install in sandbox):

https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5g000000ucw0
source code: github

b. After package installed, you’ll have a new Apex Action to execute your FuzzyWuzzy operation. The Apex Action name is: FuzzyWuzzy Scoring

Image1: New Apex Action to perform FuzzyWuzzy

c. There will be 3 Inputs and 1 Output you’ll need to config.
Inputs
FuzzyWuzzy Logic: See Supported FuzzyWuzzy logic below
String01: 1st String you want to compare
String02: 2nd String you want to compare
Output
Score: Similarity score (in percentage)

Supported FuzzyWuzzy Logic:

Basic Functions:

  1. SimpleRatio :
    Allows us to calculate the Levenshtein distance similarity ratio between the two strings (sequences)
  2. PartialRatio:
    Allows us to perform substring matching. This works by taking the shortest string and matching it with all substrings that are of the same length.
Image2: Example SimpleRatio
Image3: Example PartialRatio

The good news is you’ll be able to test the function before you install the package. You can visit this and you’ll have an access to User interface to test the FuzzyWuzzy flow.

Enjoy and drop a comment if you have troubles or feedbacks for my writing. I’ll try my best to help you folks!

Credits:

  • xdrop
  • seatgeek
  • Adam Cohen
  • David Necas (python-Levenshtein)
  • Mikko Ohtamaa (python-Levenshtein)
  • Antti Haapala (python-Levenshtein)
  • Tobias Burdow (burdoto)
  • Jason Wong (use case)

--

--

Munawirrahman
Munawirrahman

Written by Munawirrahman

A dots connector. 25x Salesforce Certified. Open for consultation, Email: munawirrahman@gmail.com

Responses (3)