Leverage the Power of Invocable MuleSoft Composer Flows.

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

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 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 invocable Composer flows to connect automation in Flow to MuleSoft Composer.

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?

Overview of data flow between Salesforce and MuleSoft Composer.

The solution

The image below shows a step-by-step guide to creating and using invocable MuleSoft Composer flows in your Salesforce org.

Overview of the Jepson Cycles’ solution.

We’ll break down the implementation into three simple steps.

  1. Create an invocable MuleSoft Composer flow.
  2. Create named credentials and register external services in Salesforce.
  3. 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.

Select trigger type ‘Invoke’ in MuleSoft Composer.

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.

MuleSoft Composer connector apps.

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.

Post Slack message action in MuleSoft Composer.

Create calendar event action in Google Calendar using MuleSoft Composer.

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.

Step in MuleSoft Composer to set the Slack message.

If the lead is assigned to a queue, we use the @here tag to tag all the sales associates.

Step in MuleSoft Composer to set the Slack message if assigned to a queue.

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.

MuleSoft Composer action to route Slack messages to the correct channel.

After activating your Composer flow, MuleSoft returns a flow URL, client ID, client secret, and OpenAPI specification.

Flow credentials information in MuleSoft Composer once the Composer flow is activated.

Step 2: Create the named credentials and register the external services in Salesforce

Overview of new named credentials approach.

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’.

External credentials configuration to connect between Salesforce and MuleSoft Composer.

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.

Named credentials configuration to connect between Salesforce and MuleSoft Composer.

Then, we’ll create a permission set to give users access to make callouts to the newly configured external service.

Configured permission set authorizing users to make callouts from Salesforce to MuleSoft Composer.

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.

Select the API source ‘From API Specification’.

Setup for an external service.

Once we save, we select the available Invoke operation and save to successfully create the external service.

Select Operations page during the external service creation process.

Step 3: Call an external service in a Salesforce flow

Here’s a visual representation of the flow solution we built.

Screen flow used in Jepson Cycles’ Experience Cloud site.

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.

Use an Action element to invoke a MuleSoft Composer flow.

To capture user details, we use a Screen element.

Use a Screen element in Flow to capture user details.

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.

Flow configuration to retrieve queue details and assign the lead to the appropriate queue.

Once we create a lead, we send the details to MuleSoft Composer using the invocable action.

Flow action to invoke the Composer flow to send the Google Calendar invite and post the Slack message.

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.

Create an Apex-defined variable resource.

We now need to store data in the newly created variable, which is passed to the MuleSoft Composer flow.

Store relevant lead information in the Apex-defined variable.

Use the invocable action to send the data to the MuleSoft Composer flow.

Send data in variable 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.

Decision element to determine whether the MuleSoft Composer flow executed successfully.

There are only three types of flows where you can call invocable MuleSoft Composer flows today.

Valid scenarios to leverage invocable MuleSoft Composer flows.

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!

Resources

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

SUBSCRIBE TODAY
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

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 […]

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