MuleSoft Automation Suite: How the components interact with each other?

Kiruthika Nithyanandan
Another Integration Blog
6 min readMay 1, 2023

MuleSoft Automation Suite consists of three components: Anypoint Platform, MuleSoft Composer and MuleSoft RPA. While each of the components have their own unique integration capabilities and could be used on their own to solve challenges, it is equally interesting to understand how they work together to open endless possibilities to create seamless and powerful automations.

MuleSoft Automation Suite

In this blog series, I would like to explore three ways that the above components could interact with each other.

· MuleSoft RPA interacting with an API published on Anypoint Platform.

· MuleSoft Composer calling an RPA process.

· Anypoint Platform calling an RPA process.

In this blog, let us start with the first one: MuleSoft RPA interacting with an API published on Anypoint Platform.

As an example, we develop a simple RPA process to fetch flight information from an API published to the Anypoint Exchange, create a csv file with the information and finally email the file to a configured email address.

The Flights API definition in Exchange looks like below:

Flights API defintion in Anypoint Exchange

The three things to note here are:

1. The API endpoint that we would use in this example is “/flights” which is of type GET.

2. The API has an optional query parameter called destination which can accept three values: ”SFO”,”LAX” or “CLE”. This can be used to filter the result to return the flights only for that destination.

3. The API calls needs to be authenticated with a client id and client secret.

The API returns a result like below:

[
{
"ID": 5,
"code": "rree1093",
"price": 142,
"departureDate": "2016-02-11T00:00:00",
"origin": "MUA",
"destination": "SFO",
"emptySeats": 1,
"plane": {
"type": "Boeing 737",
"totalSeats": 150
}
},
{
"ID": 7,
"code": "eefd1994",
"price": 676,
"departureDate": "2016-01-01T00:00:00",
"origin": "MUA",
"destination": "SFO",
"emptySeats": 0,
"plane": {
"type": "Boeing 777",
"totalSeats": 300
}
},
{
"ID": 8,
"code": "ffee2000",
"price": 300,
"departureDate": "2016-02-20T00:00:00",
"origin": "MUA",
"destination": "SFO",
"emptySeats": 30,
"plane": {
"type": "Boeing 737",
"totalSeats": 150
}
}
]

Implementation in MuleSoft RPA

The BPMN for our process looks like below:

1. The action steps to call the API and fetch the needed information to populate the CSV file.

2. The action steps to Email the CSV file

Process BPMN

Before we move on to the implementation, lets create the variables which are susceptible to change, as activity parameters. Doing this allows for easy maintenance in case there is a change in these variable values later.

Let’s us create three activity parameters:

1. API base URL

2. The format to pass the query parameter

3. Destination value to be used for the filter

4. Client id

5. Client Secret

Activity parameters for the process

Let us now implement the first Activity “Fetch info from API”.

Fetch Info from API-Full implementation

Now lets us dive into the induvidual action steps in detail:

Construct the API endpoint

The first step is to construct our full API endpoint by concatenating our activity parameters using the “Combine Strings” action step.

The full API call is of the following format:

Flights API Endpoint
Construct Endpoint

Perform REST call

Next, we perform the actual call using the “REST call” action step where we map the endpoint constructed from the previous step and the Header parameters-clientid and client secret,for authenticating our call.

Configure Base URL and Method Type
Configure Header parameters for Authentication

Create Result CSV file

Now that we have ensured that our API is returning the result that we need, our next step is to parse the result and write the data into a csv file.

To ensure a clean execution every run, let us delete the csv file if it exists, create a fresh one and write the header values into it.

Delete and Create the CSV file
Write header values into the CSV

Parse the JSON data

Since the API returns an array of flight objects, we need a loop to iterate over the result.

Inside the loop, we use JsonPath expression to get a single flight object and then read its attributes — ID, code, origin, destination and Price.You can read more on JSONPath expressions here.

In this example, the JsonPath expression,”$.[i]”, where i is the loop iteration, would return us the i-th flight object from the result.

So, we use combine strings to construct this expression dynamically based on the loop iteration and the “Json Query” to parse the result from the API call and get the corresponding flight object.

Construct JSONPath expression dynamically
Extract the corresponding flight object from the result array

Then we use “Json Query” action step again to read the individual attributes like the id, code etc. of that particular flight object.

Extract the attribute Id for the flight object

Write to CSV file

The last step in this activity is to concatenate all the read values into a comma separated string and the write it into our result CSV file.

Construct comma seperated string to write to CSV
Write the constructed row to CSV file

Email the CSV file

Finally,sending the email with the created csv as an attachment is implemented using “Mail session” and “Send mail” action steps.

Email CSV-Full Implementation

Please note that the mail session settings would depend on the mail client being used. In this example, it is Outlook 365.

Mail Session Configuration
Send mail Configuration

The process can be run and tested by pressing on the “Run Process” button.

We have reached the end of this blog, where we saw with an example, how MuleSoft RPA interacts with an API published on Anypoint Platform.

In the next follow up blogs, I would explore with examples on how Composer and Anypoint platform interact with MuleSoft RPA to create powerful automations.

Stay tuned and I hope you find this post helpful.

--

--