MuleSoft Technical Guides

Invoke Trigger in MuleSoft Composer

User MuleSoft Integration Team
Calendar October 05, 2023
Composer : Invoke Trigger

MuleSoft Composer is a user-friendly integration tool tailored for admins, business analysts, marketers, salespeople, and team leaders. Its key features include no-code integration, streamlining complex processes without the need for coding. It offers a library of 14 pre-built connectors for popular applications, reducing integration time. Users can also benefit from real-time data previews to ensure integration accuracy before activation and built-in monitoring with automated error alerts for timely issue resolution.

Composer has introduced a powerful feature called “Invoke Trigger” to simplify the execution of flows by triggering them with specific data inputs. This functionality streamlines the process of calling a Composer flow, making it exceptionally user-friendly. Let’s utilize the Invoke Trigger feature in Composer with a straightforward use case.

Consider a scenario where you have a Composer flow intended to transmit data to various end systems without relying on system calls or schedulers. In this case, you can leverage the Invoke Trigger functionality to trigger the flow while providing all the necessary variables to ensure seamless execution.

For instance, let’s examine a specific use case where we are working with Salesforce. Our goal is to update or create contacts within Salesforce, and we will be using a common account ID variable to facilitate this task. Within the Composer flow, we can set up an Invoke Trigger connector, which acts as the entry point for our flow.

Composer Flow

Here are the key steps involved:

1. Create Your Composer Flow: Start by designing your Composer flow, which should include all the necessary steps and logic for your data integration or transformation process.

2. Configure the Invoke Trigger: Within your flow, incorporate an Invoke Trigger connector. In this connector, define the fields essential for your process. For example, in our case we are updating/ creating a Salesforce contact object, this might include First Name, Last Name, Email (with email ID as a unique identifier), Phone Number, and any other relevant fields. Additionally, we establish a common account ID variable that will be used consistently throughout the flow.

Flow Variable

Invoke trigger Configuration

3. Populate the Value: The fields you created within the Invoke Trigger connector will be used within the salesforce call to update the required fields. This value will be used while calling the flow, and it will subsequently be updated in Salesforce.

Salesforce Connector

4. Test Run: After constructing the flow and implementing all the necessary logic, conduct a test run. This step is crucial for verifying that your flow correctly processes the data and functions as expected.

5. Activation: Upon a successful test run, activate the flow. Activation will provide you with a client ID and a client secret URL, along with the required payload structure within flow credentials for triggering the flow programmatically.
Note: Flow Credentials can be changed as per requirement.

Flow Credentials

6. Condition to Trigger the Flow: To execute the flow, you must send data with values that precisely match the field names specified in the Invoke Trigger connector. Ensure that the data you send aligns accurately with the defined field names.

Postman call

7. Trigger the Flow Programmatically: Utilise tools like Postman to programmatically trigger the flow. Use the provided client ID, client secret URL as username and password and payload structure provided in OpenAPI Specification to make the call. This enables you to initiate the flow from other systems or applications by leveraging the provided credentials and data.

Postman Authentication

8. Monitoring and Logging: Composer offers comprehensive logs that facilitate monitoring the success and failure of triggered calls. Regularly review these logs in the Run History section to ensure that your flow operates as intended and to troubleshoot any issues that may arise.

Run History

Let’s also verify our created contact in salesforce.

Salesforce

Yes, so we have successfully automated our flow using invoke trigger.

Leave a comment

Your email address will not be published. Required fields are marked *