Greenery and text that says "Use MuleSoft Composer to Integrate Salesforce Orgs and Slack."

Use MuleSoft Composer to Integrate Salesforce Orgs and Slack

By

As admins, once we gather and understand business requirements, we want to get building!

Have you ever been in a situation where you could build a solution yourself BUT it required an integration? You would be dependent on a developer resource to complete your solution, which adds time and cost to your project. What if you could create integrations and logic yourself, without code? Too good to be true? Well, not anymore…

A no-code integration tool for admins

MuleSoft Composer is a no-code tool, built on the Anypoint Platform, that allows admins like you to integrate apps and data quickly via prebuilt connectors. It shares the same enterprise-grade collaboration, runtime, monitoring, security, and governance capabilities. If you want your integration tool embedded directly in admin setup, you want MuleSoft Composer for Salesforce.

Note: To learn more about MuleSoft Composer for Salesforce and pricing, contact your Account Executive (AE).

You can currently trigger a Composer flow with an event in one of the following systems: Salesforce, NetSuite, Asana, ServiceNow, Google Sheets, Stripe, Xero, ZenDesk, Workday, Jira, Box, and Quickbooks Online. New connectors are added regularly.

The business problem

Contacts exist in two Salesforce orgs: Sunshine Cupcakes and Hello Mochi. These orgs are run by different business units owned by a parent company named Sunshine that decided to keep the two orgs separate. There is currently no integration in place between the orgs, but keeping data clean, up to date, and in sync between the two is time-consuming and error-prone! Sunshine would like to keep common contact data in sync without requiring manual intervention. Additionally, if a contact’s status changes to Premier, a message should be sent to a public Slack channel. Sunshine’s two developer resources are currently working on high-priority projects and don’t have the capacity to build an integration between the two Salesforce orgs.

Sync records across Salesforce orgs and collaborate in Slack using MuleSoft Composer

MuleSoft Composer is a great tool to integrate multiple Salesforce orgs and Slack without requiring any development! Addison Dogster is the system administrator for Sunshine. She has enabled MuleSoft Composer so it can be used across orgs.

The need to sync between the two Salesforce orgs can be triggered in one of two ways:

  • A contact record created or updated in Org 1
  • A contact record created or updated in Org 2

Since the trigger exists in each org, we will need to listen to them separately and take action as needed. Therefore, Addison needs to create two separate Composer flows, one for each org.

Addison needs a mechanism or unique key to link the contact records between the orgs. This would also eliminate the chance of duplicate records. Addison will use the external ID as a unique key to match contact records in both Salesforce orgs. If a contact’s ExternalId field is blank, this would signify a new contact record that has not synced to the other org yet. The external ID will serve two purposes:

  • As the foreign key reference between the orgs for the contact record
  • As a flag to determine if we need to create a new record or update an existing record:
    • If the ExternalId field is blank, we create a new contact.
    • If the ExternalId field has a value, we will update the existing contact.

There will be two Composer flows for the Contact object. The Composer flow below will sync the contact records from Org 1 to Org 2. For the bi-directional sync requirement, we will need to create another Composer flow, which will be the inverse of the Composer flow below where Org 1 is replaced by Org 2, giving us the ability to sync from Org 2 to Org 1.

Diagram of the Composer flow to sync contact data from Org 1 to Org 2

In order to send a message to Slack, we need to add additional steps to the existing process, seen in steps 4 and 5 in the diagram below. After a new contact is created in Org 2, it would check to see if the contact status is Premier. If it is, it will post to the Slack channel, seen in steps 8 and 9 in the diagram below. The process then continues for an existing contact record. After it gets the contact information for Org 2, if the contact status has changed to Premier, it will post to the Slack channel before moving on with comparing the contact fields between the two orgs.

Composer flow highlighting the new steps to post to Slack based on a new contact or updates to the contact in Org 1

In summary, Addison’s solution comprises of:

  • A new ExternalId field on the Contact object
  • Two new Composer flows to sync contact data between two orgs and post to Slack
  • HIGHLY RECOMMENDED: Two new MuleSoft Integration profiles and two new MuleSoft Integration users

Addison creates the new custom text field ExternalId to be used as the foreign key reference between the orgs for the contact record. Since the intent is to store the Salesforce record ID of the contact in the other org, we need to ensure the length is 18 characters. Also, don’t forget to check the ExternalId field to indicate that this will hold a unique identifier from an external system. The system administrator and the MuleSoft Integration user (more on that later) will need Read and Edit access to this field. Since this is a system processing field, we do not need to add the field to the page layout to be shown to the end users.

The ExternalId custom text field used as the external ID between the two orgs

Now, let’s configure two Composer flows, one for each org, in MuleSoft Composer. For the purposes of this blog, we’re going to assume you have the MuleSoft Composer licenses and have taken the necessary actions to enable MuleSoft in your org.

In the MuleSoft Composer app, select the Composer Flows tab and select New Flow.

Addison is going to configure the first Composer flow for Org 1 – Sunshine Cupcakes.

For the System Event, Addison selects Salesforce since we want this Composer flow to trigger when there’s an event in Salesforce.

System event configuration screen

Once Addison selects Salesforce, she’s asked to provide a Connection Display Name. Here, she uses the Org Name, Sunshine Cupcakes. Then, it prompts her for a Salesforce login.

Salesforce connection setup.

 

Let's chat.Let’s have a quick sidebar. While Addison could easily provide her own Salesforce credentials to continue with the configuration, this is not a best practice. Admins should NEVER use their own credentials when establishing connections between systems. Why is it a no-no? First of all, you’re a system administrator. It’s very unlikely that an integration would need full system admin access to connect to Salesforce. As a security-minded admin, you need to work with least privilege access in mind. If someone says an integration user needs system administrator access, I would challenge the vendor to identify what are the minimal permissions needed and configure the user access accordingly. Second, if you win the lottery and decide to retire from working, or once you leave the company, your user account will be deactivated. And when that happens, the integration will no longer work because the admin’s user account can no longer be used to log in. Instead, consider creating an integration user who is associated to an integration profile or the Minimal Profile – Salesforce with permission sets to cover the needed permissions.

In our case, we will initially log in to establish connection. Then, we will grant the MuleSoft Composer integration user the API Only permission. This contains the necessary CRUD access to the objects and fields the Composer needs to run on and a Salesforce license.

ImportantMuleSoft Composer is installed in production. As a result, when you create net new or make changes to an existing Composer flow, we highly recommend that you use a sandbox Salesforce connection so you can test that your integrations work as expected before switching the connections using your production credentials. If you want to test your Composer flow, create a test record so you are not testing live records in production. After your testing is complete, delete the test record.

 

Addison logs in with the MuleSoft Integration user credentials to establish the connection and allows for the connection. Note: Once the connection is established and the Composer flow is tested successfully, Addison will enable the API Only user system permission so no one can use this user account’s credentials to log in to a Salesforce interface.

Now, Addison updates the trigger name to reflect the trigger. Here, she updated it to “On new or updated record in Org 1”.

She configures it as follows:

  • Choose an event that starts this flow: New or updated record
  • Object Type: Contact
  • Result fields: <select the fields you want to use in the Composer flow> Addison chose ContactId, ExternalId, First Name, Full Name, Last Name, Business Phone, Email, and Status.

Trigger Flow element

Addison just configured the first step in the sync process when a new contact is created or updated in Org 1 – Sunshine Cupcakes.

The bi-directional sync process with arrow pointing to the first step

Next, Addison adds an If/Else Flow element that will check to see if the ExternalId field is blank. This signifies that the Contact record is new or hasn’t been synced up in Org 2 – Hello Mochi.

The criteria is set to ExternalId from Org 1 – Sunshine Cupcakes Is empty.

Then, if this is true, we need to create a new record in Org 2 – Hello Mochi. Addison creates a new Salesforce connection and logs in with the credentials of the MuleSoft Composer integration user in Org 2 – Hello Mochi. She then creates a Contact record with the First Name, Last Name, Status, and ExternalId using the first name, last name, and status. She also sets the ExternalId to the contact ID of the new contact in Org 1 – Sunshine Cupcakes.

  • Action: Create new record
  • Object Type: Contact
  • Record:
    • Last Name: 1 Last Name
    • ExternalId: 1 Contact ID
    • First Name: 1 First Name
    • Status: 1 Status
    • Business Phone: 1 Business Phone
    • Email: 1 Email

Configured If and Create new record action

The animated gif shows the actual steps Addison took to set this up.

Setting up the If/Else and create new record in Org 2 - Hello Mochi.

Addison has created steps 2 and 3 in the bi-directional sync process where we check to see if the ExternalId field is blank. She also created the Contact record in Org 2 – Hello Mochi.

The steps for checking the external ID is blank and creating the new record in Org 2 - Hello Mochi are highlighted

Next, Addison needs to add steps 3 and 4 where the Composer flow will check to see if the status field is set to Premier, and if it is, then a message will be posted to the Slack channel (#contacts-premier).

If statement:

  • Criteria: All conditions must be met (AND)
    • 1 Status Equals Premier

Action: Post message to channel in Slack

  • Action: Post message to channel
  • Channel Name: contacts-premier
  • Message: Check out this new Premier contact: 1 Full Name (ContactId: 1 Contact ID). Just joined us as a new customer today.

Configured Composer flow steps to check if the status is Premier, then post to the Slack channel if true

The animated gif shows the actual steps Addison took to set this up.

Creating the If statement to check if the status is Premier and posting to Slack if true.

Addison has completed the step of checking to see if the status field is Premier and, if so, posting a message to the Sunshine company’s #contacts-premier Slack channel.

The steps for checking if the status is Premier and, if so, posting the message to Slack are highlighted

Once the new Contact record is created in Org 2 – Hello Mochi, we need to update the ExternalId field in the Contact record in Org 1 – Sunshine Cupcakes so the contact records can be synced going forward. Remember, the external ID is the glue between the two orgs for that one Contact.

Addison configured the action as follows:

  • Action Name: Update External ID in Org 1
  • Connection: Sunshine Cupcakes
  • Action: Update record
  • Object Type: Contact
  • Record:
    • Contact ID: 1 Contact ID
    • ExternalId: 2 Id

Configured action to update the contact in Org 1 - Sunshine Cupcakes with the ID of the Contact record in Org 2 - Hello Mochi

The animated gif shows the actual steps Addison took to set this up.

Configuring the action to update the ExternalId field in the Org 1 - Sunshine Cupcakes Contact record.

Addison has completed the step of updating the Contact record in Org 1 – Sunshine Cupcakes with the ExternalId of the Contact record in Org 2 – Hello Mochi.

The bi-directional sync process highlighting the step to update the trigger record in Org 1 - Sunshine Cupcakes

Now, Addison needs to configure the Else statement. This will direct the Composer flow path if the ExternalId field from the Contact record in Org 1 – Sunshine Cupcakes is not blank. If this is true, Addison wants to get the Contact record fields from Org 2 – Hello Mochi.

Addison configured it as follows:

  • Else Name: External Id is not blank in Org 1
  • Action: Get records in Salesforce
    • Connection: Hello Mochi
    • Action: Get records
    • Object Type: Contact
    • Result fields: ExternalId, First Name, Last Name, Status, Business Phone, Full Name and Email, ContactId
    • Conditions to filter the objects: All conditions must be met (AND)
    • ExternalId Equals 1 Contact ID

Configured Else and Get records Flow elements

The animated gif shows the actual steps Addison took to set this up.

Configuring the Else and Get records action to get the Contact record information from Org 2 - Hello Mochi.

Addison has completed step 7 in the bi-directional sync process to get the Contact record information in Org 2 – Hello Mochi where the Org 2 – Hello Mochi Contact record’s ExternalId is the Org 1 – Sunshine Cupcakes Contact recordId.

The bi-directional sync process highlighting the step to get the Contact record from Org 2 - Hello Mochi

Now, Addison needs to post to Slack if the contact status changes to Premier—steps 8 and 9 of the process. She adds another If statement within the For Each loop where the status of the Org 2 – Hello Mochi Contact record is not the same as the Org 1 – Sunshine Cupcakes Contact record and the status of the Org 1 – Sunshine Cupcakes contact is Premier. If this is true, she wants to post a message to the #contacts-premier Slack channel in the Sunshine company Slack.

Addison configured it as follows:

  • For Each:
    • Input List: 5 List of Contact
  • If/Else:
  • If Statement:
    • Criteria: All conditions must be met (AND)
      • 5 Status Does not equal 1 Status
      • AND 1 Status Equals Premier
  • Action: Post message to channel in Slack
    • Connection: Post to the Sunshine Company Slack
    • Action: Post message to channel
    • Channel Name: contacts-premier
    • Message: Check out the newest Premier contact 1 Full Name (ContactId: 1 Contact ID)

The configured If/Else to check whether the status changed and the status is Premier and, if so, post to a Slack channel

The animated gif shows the actual steps Addison took to set this up.

Setting up the loop and checking to see if the status is changed and the status is Premier and, if so, post a message to the Slack channel.

Addison has completed steps 8 and 9 of checking to see if the status field has changed and is set to Premier and, if yes, then post a Slack message.

The bi-directional sync process highlighting the steps to check if the status changed to Premier and, if yes, post to Slack channel

Next, Addison needs to take the list of contacts from the Get Records action and do a comparison of field values between the contact records in Org 1 – Sunshine Cupcakes and Org 2 – Hello Mochi using another If/Else statement.

Addison made the following configuration changes:

  • Added a For Each
    • Input List: 5 List of Contact
  • Added a new If/Else
  • If Name: Fields are different between Org 1 and Org 2
  • Criteria: Any condition can be met (OR)
    • 5 First Name Does not equal to 1 First Name
    • 5 Last Name Does not equal to 1 Last Name
    • 5 Status Does not equal to 1 Status
    • 5 Business Phone Does not equal 1 Business Phone
    • 5 Email Does not equal 1 Email

Configuring a For Each, new If statement to see if there are differences between contact field values

The animated gif shows the actual steps Addison took to set this up.

Addison showing the difference in Org 1 and Org 2.

Addison has completed step 10 in the bi-directional sync process to determine whether any fields are different between the two orgs.

The bi-directional sync process highlighting the steps to compare the Org 2 - Hello Mochi contact from the Get records and the original trigger record in Org 1 - Sunshine Cupcakes, and updating the Org 2 - Hello Mochi contact with any changes

Lastly, if there are differences in the Contact records between the two orgs, Addison configures the Composer flow to update the Contact record in Org 2 – Hello Mochi using the values from Org 1 – Sunshine Cupcakes.

She configures the following:

  • Action: Update record in Salesforce
    • Connection: Hello Mochi
    • Action: Update record
    • Object Type: Contact
    • Record:
      • Contact ID: 1 ExternalId
      • First Name: 1 First Name
      • Last Name: 1 Last Name
      • Status: 1 Status
      • Business Phone: 1 Business Phone
      • Email: 1 Email

The configured update record action for Org 2 - Hello Mochi if there are differences between the two Contact records

The animated gif shows the actual steps Addison took to set this up.

The configuration for the update record in Org 2 - Hello Mochi step.

Addison completed step 11 to update the Contact record in Org 2 – Hello Mochi if there are differences between the Contact records in the two orgs, where the ExternalId field is the same as the Contact record in Org 1 – Sunshine Cupcakes. With that, Addison has configured all the steps to set the bi-directional sync from Org 1 – Sunshine Cupcakes to Org 2 – Hello Mochi.

Highlighting the last step to update the contact record in Org 2 - Hello Mochi if there are differences between the Contact records in both orgs

Addison saves the Composer flow and names it “Bi-directional sync from Org 1 to Org 2.” She selects the Test button to test her Composer flow. She tests the following scenarios by creating or modifying a Contact record in Org 1 – Sunshine Cupcakes using the test functionality and validates against the expected results.

  • Scenario: Creates a new record with status = Premier
    • New record is created in Org 2 – Hello Mochi.
    • The ExternalId field is updated in the Contact record in Org 1 – Sunshine Cupcakes.
    • A message is posted to the #contacts-premier Slack channel.
  • Scenario: Creates a new record where the status is not Premier
    • A new record is created in Org 2 – Hello Mochi.
    • The ExternalId field is updated in the Contact record in Org 1 – Sunshine Cupcakes.
  • Scenario: Updates an existing record and status is not updated and does not equal Premier, and changes are made to fields we are tracking in both orgs
    • The record in Org 2 – Hello Mochi is updated to match the fields for the contact in Org 1 – Sunshine Cupcakes.
  • Scenario: Updates an existing record and status is updated and does equal Premier, and no changes made to the other fields tracked in both orgs
    • The status field is updated in the Contact record in Org 2 – Hello Mochi to match the contact in Org 1 – Sunshine Cupcakes.
    • A message is posted to the #contacts-premier Slack channel.

Addison’s configuration work is not done yet—only half the puzzle has been solved.

Addison needs to create the second Composer flow that is the inverse of the one she just completed. We will not go through each step in detail, but here is the configured second Composer flow that fires when a new Contact record is created in Org 2 – Hello Mochi to sync with Org 1 – Sunshine Cupcakes.

The bi-directional sync between Salesforce Orgs 2 and 1 and post to Slack

Here is Addison’s configured Composer flow for the bi-directional sync from Org 2 – Hello Mochi to Org 1 – Sunshine Cupcakes. Essentially, Addison configured this as the inverse of the Composer flow she built above.

Configured Composer flow for the bi-directional sync between Org 2 - Hello Mochi and Org 1 - Sunshine Cupcakes.

Once Addison successfully tests the Composer flow using sandbox connections, she modifies the Composer flow to use production connections. Addison creates a test record to run the tests against, and once the testing is successful, she activates the Composer flow in production. Once activated, it’s ready for use!

Wow! YOU integrated two separate Salesforce orgs and Slack using clicks, not code! No developer help required. With MuleSoft Composer, the power of integration is in the hands of the admin.

What integration use cases have you built using MuleSoft Composer? Share with us @SalesforceAdmns on Twitter.

Resources

Skill Up and Utilize MuleSoft Composer

6 Resources to Help You Skill Up and Utilize MuleSoft Composer

Innovation is no longer just IT’s responsibility! In fact, more than 76% of business users like admins want to get involved in new ways to enhance internal digital services at their companies. Salesforce Admins use clicks, not code, to automate solutions. However, that often means relying on programmatic tools to connect data across systems. That’s […]

READ MORE
Cloudy in a Slackstar suit.

How Admins Can Connect Salesforce and Slack

With the Salesforce acquisition of Slack, Salesforce is realizing a major goal: to help people work from anywhere in this new all-digital world. Salesforce Admins have the opportunity to be at the forefront of this world by using Slack to surface the information their customers need when they need it. Salesforce Admins are well-positioned to […]

READ MORE

Have an Idea for a Story?

We are all about the community and sharing ideas.
Do you have an interesting idea or useful tip that you want to share?

SHARE YOUR IDEA