Max sitting on a log next to text that says, "How to Integrate Salesforce Flow with MuleSoft RPA."

How to Integrate Salesforce Flow with MuleSoft RPA

By

Salesforce Flow empowers you to build complex business solutions using clicks, not code. Flow RPA provides the ability to automate repetitive tasks using RPA Bots. Together, admins can build powerful business workflows to achieve end-to-end automation. Let’s assume we have a use case for document processing. For this use case, we’ll need the ability to extract data from PDF documents so they can be used in a larger business process. In this blog, we’ll explore how to invoke an RPA Bot directly from Flow. For the purpose of this blog, we’ll assume we have an RPA process that reads an email and extracts data from a PDF document deployed to Anypoint Exchange and is ready for integration.

Create a User API key in MuleSoft RPA Manager

User API keys are required to integrate RPA processes with third-party applications. We can create a User API key from the User Management page in MuleSoft RPA Manager. This key allows a user or client application to use this RPA process successfully. Without this key, all invocation attempts will fail. An RPA Admin can create/revoke this User API Key at any time, if needed. Once the RPA Admin creates the User API key, we can proceed to the next step.

Configure external services for MuleSoft

To use external services for MuleSoft from Salesforce, we create a new connected app to bind RPA Manager with the Anypoint organization (this allows us to easily isolate these two separate connections) and a named credential to allow the RPA automation asset import from Exchange. Refer to the steps here (Salesforce Help article) to configure the connected app and named credential for Anypoint Platform. Once done, we now have a named credential set up in Salesforce to connect with a specific Anypoint organization.

Configure an external credential for authenticating to MuleSoft RPA Manager

While the first step allowed us to discover and reuse the RPA automation within the Salesforce platform in tools like Flow Builder, it’s also necessary to set up the credentials to successfully invoke this RPA automation. The fact that you can discover and reuse doesn’t mean you’re entitled to invoke the endpoint; in the API world, you need to be entitled to the permissions to use this API at runtime. This section covers how to set this part up.

Configured Anypoint named credential to invoke the RPA automation

Create a permission set

A permission set is a collection of settings and permissions that give users access to various tools and functions. We’ll need to create and assign a permission set to enable users to invoke this MuleSoft RPA process in Flow. For our example, we call this permission set “rpapermission.”

Permission set to enable users to invoke this MuleSoft RPA process in Flow

Create an external credential for RPA Manager

We’ll need to link the external credential to a user’s permission set and to the named credential that specifies the URL for MuleSoft RPA Manager. The external credential details how Salesforce authenticates to MuleSoft RPA Manager. We first create an external credential that maps the “rpapermission” permission set we created with an authentication parameter whose value is the API key we obtained from the MuleSoft RPA Manager. Additionally, we create a custom header so we can pass in the x-apikey as a part of the API call.

External credential for adding RPA User API key

Create a named credential for MuleSoft RPA Manager

A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. We’ll now create a named credential that maps the URL of the RPA Manager instance with the external credential we created in the previous step.

Named credential for the MuleSoft RPA Manager

Invoke RPA process from Flow

Now, let’s configure an external service for the RPA Process API and invoke it from Flow.

Sample flow showcasing the use of the RPA process with Optical Character Recognition capabilities

Create an external service

An external service in Salesforce allows us to integrate APIs declaratively without using code. We’ll create an external service using the named credential we created for Anypoint Platform. We should be able to see all the RPA Process API versions. Notice that on the service configuration, we’re using the named credential we created for RPA Manager.

Configuration of external service for the RPA process

All the operations that the RPA Process API provides are now shown for the external service.

Details of external service with process definition

Create a screen flow to invoke the external service

We can now invoke the RPA process external service from a flow. First, we create a screen flow and define an Apex-defined variable to map the input variable for the process run.

Input variables for RPA process

We use an Assignment element to map the input variable. You can start the RPA process with or without an execution Id (in which case, an ID is auto-generated). We assign an execution Id so we can track it for completion. A flow interview is a running instance of a flow. Interview GUID is a unique identifier associated with a flow. You can assign this by selecting the $Flow variables from the value mapper.

Assignment of input variables for the RPA process

Finally, we’ll define an action step to invoke the RPA Process API by choosing the OCRWorkflowService from Category to invoke the external service already created.

Action to invoke the operation to start the RPA process

The flow is now ready to be tested.

Completed flow that invokes the RPA process

Notice that the request was successfully executed. The responseCode signifies the API call. 200 and 201 are both considered success response codes.

Execution status from debugging the flow

It’s also possible to check the status of the process execution with the executionId by adding an action step for the GET operation. The getProcessExecutionStatus method provides the ability to check the status of execution of the RPA process and can also return back output responses that can be used in the flow.

Execution status of the debug operation of getProcessExecutionStatus

Summary

Flow Builder and MuleSoft RPA help companies replace tedious, manual tasks with automated processes to accelerate productivity and provide better customer experiences, at scale. With simple configuration using clicks not code, it’s possible to easily discover and reuse automation assets across the organization to make end-to-end automation possible. All RPA automation created with MuleSoft RPA serves as reusable building blocks that can encapsulate the tedious details to integrate with legacy and new applications, which enables more automation capability in the hands of low-code tools like Flow Builder.

Resources

Cloudy standing near a cliff and text that says, "Easy Integrations with Flow HTTP Callouts."

Integrations Are Easier Than Ever with Flow HTTP Callouts

Are you tired of waiting for IT resources to build out an integration to your supplier? Are you frustrated that your payroll system lacks reliable application programming interface (API) documentation, leaving your IT team to weed through JSON and just hoping it’ll work? Then Flow HTTP Callout is for you! This feature does the hard […]

READ MORE
Computer monitor and text that says, "Automate with MuleSoft Composer."

Automate Your Business Process with MuleSoft Composer

Importing and exporting data is incredibly useful. But as any admin can tell you, it can also be very time-consuming. Data loads often require manual adjustments, ID mappings, and troubleshooting. Your time is valuable, and automating this process can make you a more efficient admin, freeing you up for important feature requests or maintenance. Historically, […]

READ MORE