Creating Personalized Fax Campaigns with Salesforce Sales Cloud and MuleSoft® Anypoint Studio

This tutorial explains sending personalized fax campaigns with Salesforce Sales Cloud and MuleSoft Anypoint Studio. It includes the following key steps:

  • Designing a user interface (UI) for selecting the recipients of a fax campaign in Salesforce Sales Cloud.

  • Transferring the campaign recipient data from the UI to an APEX class to process this data and send it to the MuleSoft platform (Anypoint Studio).

  • Processing data on the Mulesoft platform and dispatching faxes to the Retarus infrastructure via a REST API call.

The flow of data through these steps is illustrated below:

Personalized fax campaigns - data flow





  • For Retarus Cloud Fax , an active Retarus test agreement, proof of concept (PoC), or contract.
    If a test agreement is required, fill out the contact form or speak with a Retarus representative.

  • Account credentials (also known as “Login ID”) with a username and password.

    Each Retarus customer typically has a primary identifier for all booked services - the customer number. Multiple login IDs can be created for the same customer number (or tenant). This makes it possible to create different processing configurations to accommodate different people, departments, or purposes.

Steps overview in Salesforce Sales Cloud

A designed Salesforce campaign page that is used as an example in this tutorial looks like this.

Personalized fax campaigns - campaign page

A new fax campaign can be launched by following these steps:

  1. In the Campaigns tab, activate the checkboxes next to the desired fax campaign addresses and select Next.

    Personalized fax campaigns - selecting addresses

  2. Review the chosen recipients and select Next.
    This starts the fax campaign and displays a message indicating that the fax data has been successfully sent.

    The displayed message only indicates that data was sent out to the Anypoint Studio IDE. It does not confirm the successful transmission of the fax.

    Personalized fax campaigns - data transmission message

    A personalized fax campaign can be dispatched by combining an HTML Personalization Coversheet uploaded to the EAS portal with an overlay sheet in *.tif format.

    Personalized fax campaigns - example

Designing a flow in Salesforce Sales Cloud

The basic flow in Salesforce Sales Cloud for sending fax campaigns is shown below:

Personalized fax campaigns - logic

The following blocks are used to build the flow.


Get all contacts using the RecordCollection data structure.

Personalized fax campaigns - getting contacts


Create a screen with a table for selecting recipients, including definitions for customizable columns.

Personalized fax campaigns - creating a data table screen


Create a customer filter screen to ensure the correct recipients are selected in the contacts.


Iterate over the recipients selected for the fax campaign, sending personalized faxes to each (using one REST call per recipient) via an APEX Action.

Note: For larger campaigns, consider combining all faxes into a single REST call to stay within the daily REST call limits set by the end customer’s Salesforce contracts.

Personalized fax campaigns - looping element

Edit the loop element.

Personalized fax campaigns - looping element

Edit the Apex action.

Personalized fax campaigns - looping element

Below is the APEX code for this personalization. The personalization process is done on a per-document basis. A single REST API call is used to transfer a recipient’s personalization strings to the Mulesoft Anypoint Platform endpoint.

Alternatively, the Anypoint Platform or any other REST API call processing platform can be used instead of the local Anypoint Studio IDE. It is necessary to open a dedicated port to connect from Salesforce while using the Anypoint Studio IDE. NGROK can be used for testing purposes, but note that it involves opening the computer port to external entities (this should only be done for testing purposes or not at all).

The running interface of NGROX is shown below:

Personalized fax campaigns - NGROX interface

Apex code

global class RetarusFaxApi { @InvocableMethod(label = 'Send Fax Campaign' description='method description')

global static void callFaxApi_in(faxRequest[] requests){
   for (faxRequest request: requests) {
      Http http = new HTTP();
      HttpRequest req = new HttpRequest();
      HttpResponse res = new HttpResponse();
      String FirstName = request.FirstName;
      String LastName = request.LastName;
      String FaxNumber = request.FaxNumber;
      String ContactId = request.ContactID;
      JSONGenerator gen = JSON.createGenerator(true);
      String jsonS = gen.getAsString();
      res = http.send(req);
global class faxRequest {
   global String FirstName; 
   global String LastName; 
   global String FaxNumber;
   global String ContactID;       


Designing a flow in Anypoint Studio

Transforming the message

Personalized fax data is processed in the Transform Message block.

Personalized fax campaigns - Anypoint Studio logic

Below is the data output as a JSON snippet.

%dw 2.0
output application/json
    "reference": {
        "customerDefinedId": "Retarus DE",
        "billingCode": "99999",
        "billingInfo": "Testing Faxes"
    "recipients": [
            "number": payload.FaxNumber,
            "properties": [
                    "key": "FromName",
                    "value": payload.FirstName
                    "key": "FromCopanyName",
                    "value": "Retarus IT"
                    "key": "ToName",
                    "value": payload.LastName
                    "key": "ToCompanyName",
                    "value": payload.ContactID
                    "key": "ToFaxNum",
                    "value": payload.FaxNumber
                    "key": "barcodeValue",
                    "value": "123456789"

"statusReportOptions" : {
"reportPurgeTs" : "2018-11-03T20:14:37.098+02:00",
"reportMail" : {
"successAddress" : "",
"failureAddress" : "",
"attachedFaxImageMode" : "SUCCESS_ONLY",
"attachedFaxImageFormat" : "TIFF"
"httpStatusPush" : {
"targetUrl" : "",
"authMethod" : "NONE"
    "meta": {
        "customerReference": "66666",
        "jobValid": {
            "start": null,
            "end": null
    "renderingOptions": {
        "paperFormat": "A4",
        "resolution": "HIGH",
        "header": "%tz=CEST Testfax: CSID: %C Recipient Number: %# Date: %d.%m.%Y"
    "transportOptions": {
        "csid": "REST Test"

Processing the request block

The request block sends data to the Retarus infrastructure in the JSON format specified in the transform message block, as detailed in the configuration below.

Personalized fax campaigns - request block