How to Invoke a MuleSoft Composer Flow from Flow Builder

A step by step guide

Dave Norris
4 min readSep 10, 2023

MuleSoft Composer lets you create system to system integrations. The trigger for the integration can be either an event in that system, on a schedule or by http invocation. This opens up the possibility to invoke Composer flows from Flow Builder in Salesforce.

Let’s take a look how.

First let’s setup a Composer Flow that can be triggered from an external system by selecting that option when creating a new flow.

Our example flow will have input parameters. In order to specify the input click the Add Input Fields button.

Here you can specify the input variables, their data types, some sample values and some help text. Our example lets the external system pass in values for greeting and place.

We’ll concatenate the variables passed into the Composer Flow so that it will display the greeting then the place into a variable.

After you activate the flow a flow credentials button becomes available.

This button gives you access to the URL, Client ID, Client Secret and OAS Specification. Keep track of each value as we need them later.

Now let’s create a named and external credential that can use the flow credentials when we need to callout from Flow Builder.

First create an external credential Setup->Named Credentials then select the External Credential tab. We’ll call ours Greeting Flow Auth and we’ll select Custom under the Authentication Protocal dropdown.

Next we create a principal with 2 authentication parameters. Username and Password. The values used are from our Flow Credentials. Username is Client ID and password is Client Secret.

Then we need to create a custom header to include our authentication details. The values for username and password need to be BASE64 encoded using the formula below.

{!’Basic ‘ & BASE64ENCODE(BLOB($Credential.Greeting_Auth_Flow.Username & ‘:’ & $Credential.Greeting_Auth_Flow.Password))}

When we have our external credential we then create a named credential called Composer Greeting Flow and use the URL from the Flow Credentials. We then select the External Credential we just created and we make sure to tick the checkbox for Allow Formulas in HTTP Header.

Now we’re ready to create an External Service. Setup->External Service. Then click Add an External Service.

Select From API Specification.

Then copy and paste the OAS Specification from our Flow Credentials.

Then click Save and Next. Then select the operation that will ultimately call the Composer flow.

Here you can see the Apex class that will be created automatically for you to call from Flow Builder. Click Finish.

Now we can create our Flow. Using Setup->Flow click New Flow. Then select Screen Flow.

Create a new variable resource type. This needs to be an Apex-Defined data type selecting the Apex class that was created for us when we created the external service.

Add a assignment element as the first step in your new flow to set the variables to pass into the Composer Flow. Here we can select the variable we chose above which gives us access to greeting and prompt that we defined in our Composer Flow.

Now we’re ready to create the callout. We add a new Action and in the left hand navigation you’ll see a placeholder for our External Service. Select it and click Done.

Your Flow should now look like the screenshot below.

--

--

Dave Norris

Developer Advocate @ Salesforce || Interested in solving unique challenges using different cloud service providers || All opinions are mine.