Create a 360-Degree View of Donors with Flow Builder and MuleSoft Composer.

Automate This! — Create a 360-Degree View of Donors with Flow Builder and MuleSoft Composer

By

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, see how Andrew Shanks uses Flow Builder and MuleSoft Composer to bring data from third-party systems that would otherwise escape the grasp of their Salesforce data, in efforts to create a better 360-degree view of their donors.


Use case

At the Oregon Humane Society, we’ve started the long journey of building a 360-degree view of our donors, adaptors, volunteers, and other patrons. We recently opened up our Community Veterinary Hospital and want to bring data from our Veterinary Software, ezyVet, into Salesforce. The specific data we want revolves around the Contacts, Animals (patients), Appointments, Invoices, and Tags (financial aid).

This needs to happen on a daily basis and must avoid missing any data, given that records can be created 24 hours a day.

The benefits of this integration

  • Eliminates a data black hole (or silo) in our organization
  • Increases our potential donor pool by 2,000 people monthly (if they agree to the Pardot marketing flow)
    • This single integration has already raised enough money that it’s fully paid for the whole MuleSoft automation package after 6 months.
  • Gets the Oregon Humane Society one step close to our 360-degree view

The solution

The order of the data we’re bringing in must be taken into consideration.

  1. We bring in the contacts first because animal records should be attached to a household.
  2. Animal records come in second.
  3. Appointments are third since contacts and animals are required fields for appointments to be created.
  4. Invoices are fourth with a contact and animal relationship also required.
  5. Tags come last... because it was a late addition (gotta love the scope creep).

We use a combination of a Salesforce scheduled flow to start the process and the move to MuleSoft Composer to pull in the data using their HTTP Connector. After each type of data, MuleSoft updates the custom object we created in Salesforce to show that one process is done and to trigger the next one on the list.

We’re also passing data from Salesforce to the MuleSoft Composer flow to ensure that we pull data that has been updated within the last 24 hours with a very specific timestamp.

Salesforce to MuleSoft back and forth process.

Custom object/fields and flows

There are a few background items that I’ve set up to help with this automation.

  • Custom Object: URL Fields
  • Custom Fields: To pass info back and forth from Salesforce to MuleSoft
    • What’s with that third field, ezyVet URI for > than Yesterday at 4pm? ezyVet API requires URI encoding for saying things like ({“gt”:1697238000}) — aka greater than the Unix Timestamp for Yesterday at 4pm. Shoutout to Dan’s Tools for making this easier.

URL Fields custom object.

  • Scheduled flow: Checks the “Get New Token” box (4am, Noon, 8pm). The token expires every 8 hours.

Salesforce flow to mark "Get New Token" as True.

  • Record-triggered flow: When “Get New Token” = True, perform a HTTP Callout to get a new token, and modify it to include “Bearer” at the start.

Record-triggered flow containing an HTTP callout action to get new token from ezyVet.

  • Scheduled flow: Mark “Get ezyVet Contacts” = True at 4pm daily to start all of the automation.

Scheduled flow that sets "Get ezyVet Contacts" = True.

MuleSoft Composer

With the foundation out of the way, let’s focus on what’s happening within MuleSoft Composer. Below is a screenshot of the whole process. Let’s dive in and see what we’ve got going on.

MuleSoft Composer flow for our ezyVet integration.

Step 1: Trigger on new or updated record. The object is our custom URL Fields object, and the URL fields name contains “MuleSoft URLs”.
Step 2: This is my automation on/off switch. I’m turning my flows off for my MuleSoft ezyVet User because I was hitting errors when trying to import up to 200 contacts at a time.

Step 2: Turn off the on/off switch for the Flow Automation user.

It’s no mistake. I spelled my object type automation with two A’s! That way, it shows up at the top of the list whenever I click on “Settings” in a flow :-).

Step 3: We enter the If/Else statements. The five main statements are looking at the MuleSoft URLs record and seeing which of the checkboxes is checked.

Step 4: If Get ezyVet Contacts = True, then do this process:

  • We’re going to start our API calls to ezyVet using the MuleSoft Composer HTTP Connector.
  • ezyVet breaks the Contact information into three different API calls, which is fun!
    • Contact: Gives us the contact ID, contact code, first name, last name, and some checkbox fields.
    • ContactDetail: Multiple records per contact, one record for each individual phone number and each individual email.
    • Address: Includes street, city, state, and postal code. There can also be multiples of these per contact.
  • I need to get the name and email before checking Salesforce for a matching contact.
    • Get Contacts created since 4pm yesterday that are active and not a business.

Showing my URL Fields custom fields being used in the API callout in MuleSoft.

Miro board of the Contact process for the ezyVet Integration.

Now, we’ll loop through each item:

  • First, we do a Get ContactDetails to retrieve the matching ezyVet contact ID and value (%7B%22like%22%3A+%22%40%22%7D).
    • Ahhh, what? That’s URI encoding for ({“like”:“@”}) — aka Contains ‘@’ which is required in an email.
  • If we find records (aka our list of ContactDetails is NOT empty), then we loop those items.
  • Start error handling: How to Configure Error Handling in MuleSoft Composer
    • We do a Get Records in Salesforce to retrieve the matching first name, last name, and email AND the email is not blank (based on the information I’ve gotten from ezyVet so far).
    • If we find a matching record, we update the Salesforce contact with the ezyVet contact ID and contact code.
    • If we don’t find a contact match, then we create a contact and do another API callout for ContactDetails.
    • Next, we loop the Contact Details to assign phone numbers and email address.
    • While setting the phone number, we get the address and set that as well.
  • End error handling: Create an Admin Log (custom object) with the information we need/want.
    • The creation of an Admin Log record also triggers a MuleSoft Composer flow that uses the contact ID and contact code to update the Salesforce record.
  • Lastly, we update the MuleSoft URL record to the following:
    • Get ezyVet Contacts = False
    • Get ezyVet Animals = True

That takes us all the way down to Step 38! Then, we rinse and repeat, so I’ll do a speed-run summary of the other steps.

Steps 38-53: Get Animals

  • We do a Get Animals to retrieve the animal records created since 4pm yesterday.
  • Then, we match animal record’s contact ID with the Salesforce ezyVet contact ID field.
  • Lastly, we create and assign the animal record to the account of the matching ezyVet contact ID. If there’s no match, then don’t create the animal. We only create them when it matches a contact/account.

Steps 54-73: Get Appointments

  • We do a Get Appointments to retrieve appointments that are active, contact ID is not blank, and the animal ID is not blank.
  • Then, we find a matching contact, find a matching animal, and create the appointment record.
  • If we don’t find a matching contact and animal, we don’t create the appointment.

Steps 74-93: Get Invoices

  • Use the exact same process and criteria as Steps 52-73: Get Appointments.

Steps 94-112: Get Tags

  • This is the only one we’ll actually perform updates and not just record creations. This is because people will apply for financial assistance and then that will be made inactive while a different tag is created if they are approved. We want to track all of this to see if they have been accepted (most all of them are) or not.
  • We perform a Get Tags for records modified since yesterday at 4pm and exclude “New Client Paperwork” and where the associated type = Contact.
  • Next, we find a contact using the ezyVet contact ID.
  • If we find a contact, then we’ll find a matching tag ID. If we find the matching tag ID, then update the record.
  • If we don’t find a matching tag ID, then we’ll create a Tag record on that matching ezyVet contact ID.
  • If we don’t find a matching ezyVet contact ID at the start, then we skip the rest of the Get Tags steps.

Step 113:

  • Turn the AAutomation Setting back on for the MuleSoft ezyVet user.

You can do it!

This was a fun and unique use case, but please know that most use cases are not this complicated. I’ve been able to set up much easier integrations with Wordpress/Gravity Forms and other platforms with MuleSoft Composer and Salesforce. There’s a growing need for knowledgeable people in the MuleSoft community, so start now to carve out your niche within the platform and build your expertise! The community is here to support and help you along your journey, just as they have helped me. This whole process wouldn’t have been possible without the help from the MuleSoft community. You can join below—check out the link for the MuleSoft Composer Trailblazer Community Group!

Resources

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
Leverage the Power of Invocable MuleSoft Composer Flows.

Automate This! — Leverage the Power of Invocable MuleSoft Composer Flows

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, see how Meghesh Shenoy uses invocable MuleSoft Composer […]

READ MORE
Jennifer Cole next to text that says, "Automate Asset Management with Flow and MuleSoft Composer."

Automate This! — Asset Management with Flow and MuleSoft Composer

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by #AwesomeAdmin Trailblazers like you. Automation allows you to remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Jennifer Cole increased efficiency for […]

READ MORE