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 flows to automate a sales business process leveraging Experience Cloud, Flow Builder, and Slack.
What is MuleSoft Composer?
MuleSoft Composer is part of the MuleSoft automation package where admins, marketers, or any business user can build integrations swiftly without any prior coding or integration experience.
“Automate anything, empower everyone, and deliver success now!”You may have come cross this phrase recently. It makes sense, since MuleSoft provides users with easy access to build and deliver end-to-end automation. Using MuleSoft, you can integrate legacy systems with modern day applications using clicks, not code, allowing users to connect multiple systems seamlessly.
Use case
John Smith wants to start cycling as part of his New Year’s resolution to be more fit. He visits Jepson Cycles’ website and is impressed with their 26T MTB electric bicycle. He sees an interest form and fills it out immediately. But what comes as a surprise to John is that after he fills it out no one contacts him, and he doesn’t receive any acknowledgement or an invite from the sales associate.
How can a Salesforce Admin help solve this problem for Jepson Cycles?
The solution
The image below shows a step-by-step guide to creating and using invocable MuleSoft Composer flows in your Salesforce org.
We’ll break down the implementation into three simple steps.
Create an invocable MuleSoft Composer flow.
Create named credentials and register external services in Salesforce.
Leverage external services in the Salesforce flows.
Step 1: Create the invocable MuleSoft Composer flow
Set the trigger as ‘Invoke’, which makes the current MuleSoft Composer flow invocable.
To send the invitation to the customer, we use the Google Calendar connector. To send the message to the Slack channel, we use the Slack connector.
To configure the Google Calendar and Slack connectors, we need to first build a connection from Composer to the Google Calendar and Slack, and then select an Action we want to perform.
We customize the Slack message depending on who is assigned lead owner. If the lead owner is a user, we’ll retrieve the sales associate’s details from Jepson Cycles’ Slack workspace and at mention the user when the Slack message is posted on the Slack channel.
If the lead is assigned to a queue, we use the @here tag to tag all the sales associates.
To route product inquiry messages to their respective channels, we use the If/Else block with a condition that if a customer is interested in electric equipment, then the message should be posted on the ‘jepson-electric-developer-days’ Slack channel; otherwise, post the message to the ‘jepson-non-electric-developer-days’ Slack channel.
After activating your Composer flow, MuleSoft returns a flow URL, client ID, client secret, and OpenAPI specification.
Step 2: Create the named credentials and register the external services in Salesforce
A named credential specifies a callout endpoint and an HTTP transport protocol. An external credential’s authentication protocol and user credentials authenticate the caller. More than one named credential can use the same external credential. For example, if we want to make callouts to multiple resources available under the same external system, we create multiple named credentials but use a single external credentials so that the sensitive authentication information isn’t duplicated in Salesforce.
We need to further map external credential principals to user permissions to authorize certain users to make the callout.
Now, we’ll create the external credentials.
The client_id and client_secret parameters are stored under the Principals sections.
To reference the client ID and client secret in a custom header, you’ll use ‘$Credential.[Your External Credentials Name].client_id’ and ‘$Credential.[Your External Credentials Name].client_secret’.
Note: MuleSoft Composer only supports basic authentication, which means you have to pass the information as ‘Basic ’ and the Base64 encoded value of ‘client_id:clientsecret’.
Next, we’ll create the named credentials.
Use the same external credentials which contain the authentication information.
The URL field contains the URL which was returned by MuleSoft Composer after activating the flow.
Then, we’ll create a permission set to give users access to make callouts to the newly configured external service.
Next, let’s create the external services.
While selecting an API source, we choose the From API Specification option.
To create the external service, we need the named credentials and the OpenAPI specification, which was returned by MuleSoft Composer after activating the flow.
Once we save, we select the available Invoke operation and save to successfully create the external service.
Step 3: Call an external service in a Salesforce flow
Here’s a visual representation of the flow solution we built.
After we create the external service, the invocable action is automatically created. To leverage the invocable action in Flow, we create a new Action element.
Search for and select the newly created external service name.
To capture user details, we use a Screen element.
Once we retrieve the appropriate queue details using the Get Records element, we assign the newly created lead to the queue. For example, if the customer is interested in purchasing an electric bike, the lead is assigned to the Electric Queue.
Once we create a lead, we send the details to MuleSoft Composer using the invocable action.
We pass information to MuleSoft Composer via the external service to automate the business process for Jepson Cycles. To pass data, we create an Apex-defined variable.
We now need to store data in the newly created variable, which is passed to the MuleSoft Composer flow.
Use the invocable action to send the data to the MuleSoft Composer flow.
We use a Decision element to determine whether the Mulesoft Composer flow executed successfully. If it was successful, we use the responseCode variable available as part of the Invocable Action outcome and show a success message. If there was an error, we navigate the customer back to the previous screen to refill the details again.
There are only three types of flows where you can call invocable MuleSoft Composer flows today.
Let’s recap
MuleSoft Composer flows give an external system the ability to explicitly make a callout and execute the particular Composer flow in order to drive the business process. By creating an invocable Composer flow and named credentials, and registering and leveraging external services in Salesforce, we successfully automated the entire business process for Jepson Cycles and solved their communication problem. And we did it all without code!
This is just one example of how to seamlessly connect legacy systems and modern applications using invocable MuleSoft Composer flows. We hope this post inspires you to explore the possibilities of MuleSoft’s end-to-end automation capabilities in your Salesforce orgs!
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 […]
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 […]
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 Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Bradley Condon built the […]