Estimated reading time: 8 minutes
Mulesoft, a leading integration platform, plays a crucial role in connecting Salesforce with the external world. It acts as a middleware layer, facilitating communication and data transformation between disparate systems. Mulesoft can leverage Events, Microservices, and APIs to achieve robust and scalable Salesforce integrations. Let’s explore each of these with a specific focus on how Mulesoft facilitates the integration.
1. Integration using Events with Mulesoft
Mulesoft excels at handling event-driven architectures, enabling Salesforce to both publish and subscribe to events in a decoupled manner.
Salesforce as an Event Publisher (via Mulesoft)
Mulesoft can subscribe to Salesforce events and then route or transform these events for consumption by other external systems.
- Mulesoft Salesforce Connector (CDC): Mulesoft can use its Salesforce Connector to subscribe to Change Data Capture (CDC) events. When records in Salesforce are created, updated, or deleted, Mulesoft receives these events in near real-time.
- Mulesoft Salesforce Connector (Platform Events): Mulesoft can also subscribe to custom Platform Events published by Salesforce.
Use Case: Real-time Order Fulfillment Notification
When a Salesforce Order is fulfilled, notify an external logistics system in real-time using Mulesoft.
- Method:
- 1. Enable Change Data Capture for the
Order
object in Salesforce. - 2. A Mulesoft flow is configured with the Salesforce Connector to subscribe to
OrderChangeEvent
events. - 3. When an Order’s
Status
field changes to ‘Fulfilled’ in Salesforce, anOrderChangeEvent
is published. - 4. Mulesoft receives this event. The Mulesoft flow can then transform the Salesforce event data into the format expected by the external logistics system (e.g., a JSON payload).
- 5. Mulesoft then uses another connector (e.g., HTTP Connector) to send the transformed data to the logistics system’s API endpoint.
Salesforce as an Event Subscriber (via Mulesoft)
Mulesoft can listen to events from external systems and then trigger actions or create/update records in Salesforce.
- Mulesoft Listeners: Mulesoft can listen to events from various external systems (e.g., message queues like Kafka or JMS) using its wide range of connectors.
- Mulesoft Salesforce Connector (Create/Update): Once an external event is received and processed by Mulesoft, the Salesforce Connector can be used to create or update records in Salesforce.
Use Case: Processing External Support Tickets into Salesforce Cases
When a new support ticket is created in an external system and published to a Kafka topic, Mulesoft processes it and creates a Salesforce Case.
- Method:
- 1. The external support system publishes new ticket information to a Kafka topic.
- 2. A Mulesoft flow is configured with the Kafka Connector to subscribe to this topic.
- 3. When a new message arrives on the Kafka topic, Mulesoft receives the ticket data.
- 4. The Mulesoft flow transforms the external ticket data into the format required by the Salesforce
Case
object. - 5. Mulesoft uses the Salesforce Connector to create a new
Case
record in Salesforce, mapping fields from the transformed data.
2. Integration using Microservices with Mulesoft
Mulesoft is inherently designed to build and orchestrate microservices. It can act as a service orchestrator, calling various external microservices and also exposing Salesforce functionality as microservices.
Salesforce Calling External Microservices (via Mulesoft)
Instead of Salesforce directly calling external microservices, it can delegate this responsibility to Mulesoft, which can handle orchestration, error handling, and security.
- Mulesoft HTTP Connector: Salesforce (via Apex Callouts or Salesforce Functions) can call a Mulesoft API endpoint. The Mulesoft flow then uses the HTTP Connector to interact with various external microservices.
- Mulesoft Orchestration: Mulesoft can orchestrate calls to multiple microservices, aggregate their responses, and then send a consolidated response back to Salesforce or perform actions in Salesforce using its connector.
Use Case: Comprehensive Customer Profile Retrieval
When a customer record is viewed in Salesforce, Mulesoft retrieves a comprehensive customer profile by aggregating data from multiple external microservices (e.g., marketing data, support history, loyalty program details).
- Method:
- 1. When a user views a Contact record in Salesforce, a Lightning Web Component (LWC) or Apex code makes a callout to a Mulesoft API endpoint, passing the
ContactId
. - 2. The Mulesoft API flow receives the request.
- 3. The Mulesoft flow uses HTTP Connectors to call multiple external microservices: a Marketing Service (to get campaign engagement), a Support Service (to get recent tickets), and a Loyalty Service (to get points and tier).
- 4. Mulesoft aggregates the responses from these microservices.
- 5. Mulesoft transforms the aggregated data into a format suitable for display in Salesforce.
- 6. Mulesoft sends the transformed data back to Salesforce, which the LWC or Apex code then displays to the user.
External Systems Calling Salesforce (via Mulesoft as a Microservice Layer)
Mulesoft can expose Salesforce data and functionality as well-defined and managed microservices for external consumption.
- Mulesoft Salesforce Connector (Query/CRUD): Mulesoft APIs can use the Salesforce Connector to query and manipulate Salesforce data.
- API Management: Mulesoft API Manager provides tools to secure, manage, and monitor these exposed Salesforce microservices.
Use Case: Exposing Salesforce Product Catalog to an E-commerce Platform
An external e-commerce platform needs to retrieve the Salesforce product catalog to display products for sale.
- Method: Mulesoft as a Microservice Layer
- 1. A Mulesoft API is developed with an endpoint (e.g.,
/products
). - 2. The Mulesoft API flow uses the Salesforce Connector to query the
Product2
object in Salesforce, retrieving relevant fields like name, description, and price. - 3. Mulesoft transforms the Salesforce product data into a standard format (e.g., JSON) suitable for the e-commerce platform.
- 4. The e-commerce platform calls the Mulesoft API endpoint to retrieve the product catalog.
- 5. Mulesoft returns the transformed product data to the e-commerce platform.
- 6. The Mulesoft API can be secured and managed using Mulesoft API Manager.
3. Integration using APIs (Directly via Mulesoft)
Mulesoft acts as a central hub for managing and orchestrating API interactions between Salesforce and the external world.
Salesforce Calling External APIs (via Mulesoft as a Proxy/Orchestrator)
Instead of direct Apex callouts, Salesforce can interact with external APIs through Mulesoft, providing benefits like centralized security, logging, and transformation.
- Mulesoft HTTP Connector: Salesforce calls a Mulesoft API endpoint, which then uses the HTTP Connector to interact with the target external API.
- Security Policies: Mulesoft API Manager can enforce security policies (e.g., OAuth, rate limiting) on the Mulesoft API endpoint, securing the interaction.
- Transformation: Mulesoft can transform the data format between Salesforce and the external API.
Use Case: Geocoding Salesforce Addresses
When a new Account with a billing address is created in Salesforce, use an external geocoding API to retrieve its latitude and longitude via Mulesoft.
- Method:
- 1. An Apex trigger (
after insert
) on theAccount
object detects new records with a billing address. - 2. The trigger makes an HTTP callout to a Mulesoft API endpoint, passing the billing address details.
- 3. The Mulesoft API flow receives the request.
- 4. Mulesoft uses the HTTP Connector to call the external geocoding API, potentially transforming the address format if needed.
- 5. The geocoding API returns the latitude and longitude.
- 6. Mulesoft transforms the geocoding API response and sends it back to Salesforce.
- 7. The Apex trigger updates the
BillingLatitude__c
andBillingLongitude__c
fields on the Account record.
External Systems Calling Salesforce APIs (via Mulesoft as a Gateway)
Mulesoft can act as an API gateway, providing a controlled and managed entry point for external systems to access Salesforce APIs.
- Mulesoft Salesforce Connector (REST/SOAP): Mulesoft APIs use the connector to interact with Salesforce APIs.
- API Management: Mulesoft API Manager provides security, rate limiting, monitoring, and analytics for these APIs.
- Transformation and Orchestration: Mulesoft can transform data formats and orchestrate calls to multiple Salesforce APIs if needed.
Use Case: External Partner Portal Accessing Salesforce Data
An external partner portal needs to retrieve and update lead information in Salesforce.
- Method: Mulesoft as API Gateway
- 1. Mulesoft develops APIs that interact with the Salesforce REST API (using the Salesforce Connector) to query and update
Lead
records. - 2. These Mulesoft APIs are exposed to the external partner portal through a defined set of endpoints.
- 3. Mulesoft API Manager enforces security policies (e.g., API keys, OAuth) to control access from the partner portal.
- 4. The partner portal calls the Mulesoft APIs to retrieve and update lead data.
- 5. Mulesoft handles the interaction with Salesforce, including data transformation and error handling, and returns the appropriate response to the partner portal.
Conclusion
Mulesoft significantly enhances Salesforce’s ability to integrate with the external world using Events, Microservices, and APIs. It provides a robust platform for building, managing, and securing these integrations, offering capabilities like data transformation, orchestration, and centralized management. By leveraging Mulesoft’s connectors and API management features, organizations can create seamless and scalable connections between Salesforce and their diverse ecosystem of applications and services.
Leave a Reply