Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Create a Flow

Learning Objectives 

After completing this unit, you’ll be able to:

  • Prepare to create a flow.
  • Create a flow.
  • Add a trigger to a flow.
  • Add action steps to a flow.
  • Exit a flow.

Before You Start

This module builds on MuleSoft Composer Basics and MuleSoft Composer Installation and Configuration. In these modules, you learn about MuleSoft Composer features, flow components, flow creation tasks, and the requirement to have the MuleSoft Composer User permission set to build and run flows. So make sure to complete these modules before you continue.

In this module, we assume you’re an authorized MuleSoft Composer user. If you’re not a MuleSoft Composer user, that’s OK. Read along to learn how they perform the steps. Don’t try to follow the steps in a Trailhead Playground, because MuleSoft Composer isn’t available in the Trailhead Playground. 

Now, you step into the role of admin for Northern Trail Outfitters (NTO), an outdoor and recreational gear retailer. In this module, you examine some key integration challenges faced by NTO and learn how to use MuleSoft Composer to solve them. 

Prepare to Create a Flow

Ready to get started?

First, gather all required information about the systems and assets your flow is going to use. 

Let’s say you want to automate the data sync between Salesforce, NetSuite, and Slack. The following table describes the systems your flow must connect to and the information you need for those systems.

System

Required Information

Salesforce

  • URLs of your sandbox and production orgs
  • Username and password with appropriate permissions to the orgs

NetSuite

  • NetSuite URL
  • Username and password with appropriate permissions
  • Account ID of your organization’s NetSuite implementation
  • Consumer key and consumer secret
  • Token ID and token secret

Slack

  • Workspace
  • Channel
  • User ID and password with appropriate permissions

As a best practice, use a test environment for systems and data when you design and test your flows. After you’re done with testing, run the flows using your production systems and data.

Next, when you create a connection to a system using MuleSoft Composer, you’re typically required to grant MuleSoft Composer permissions to the system. Ensure your user account for the system is ready to grant MuleSoft Composer appropriate permissions.

For example, when you create a connection to Salesforce, your user account is required to grant MuleSoft Composer the following permissions.

  • Access the identity URL service.
  • Manage user data via APIs.
  • Perform requests at any time.

Finally, to cross-reference data between systems, you must create relevant custom fields in the systems. For example, to cross-reference Salesforce products with NetSuite inventory items. In this case, you create a custom field in NetSuite to capture the Salesforce product IDs and a custom field in Salesforce to capture the NetSuite inventory item’s internal IDs.

To learn how to create custom fields in Salesforce, see Customize a Salesforce Object. To learn how to create custom fields in other systems, consult the documentation for those systems.

Create a Flow

After you’ve gathered all required information about the systems and assets your flow is going to use, you’re ready to create the flow.

Follow these steps to create a flow.

  1. Log in to your NTO org using your username and password.
  2. From the App Launcher, enter Composer and select MuleSoft Composer.
  3. Click Create New Flow.
    Welcome to MuleSoft Composer page with a Create New Flow button.
  4. Click the pencil icon next to the default flow name.
    Untitled flow.
  5. Name the flow and click Save to save the flow name.
    Flow Name dialog box.
  6. Click Save to save the flow.
    Save button.

Add a Trigger to a Flow

Every flow must have one of the following triggers to start. 

  • System event trigger
  • Scheduler trigger

Use a System Event as a Trigger

You can use an event such as creating or updating a record in a system as a trigger for your flow. To do this, use one of the connectors MuleSoft Composer provides. MuleSoft Composer adds new connectors to a variety of systems on an ongoing basis.

Note

Some connectors work as both triggers and actions in a flow. Other connectors work only as actions. If you know MuleSoft Composer supports certain connectors but they don't appear in the list of available connectors as triggers, those connectors are likely available as actions.

Let’s learn how to add the creating or updating of an account in the NTO sandbox org as a trigger to your flow.

Follow these steps to add a Salesforce event as a trigger to a flow.

  1. On the What Should Start This Flow dialog box, select Salesforce from the list of available connectors.
    System Event page with available connectors.
  2. Click Add new Salesforce connection to create a connection to the NTO sandbox org.
    Note: If this is your first Salesforce connection, this option doesn’t appear. Go to the next step.
  3. Name the connection NTO sandbox org.
  4. Select the checkbox This is a sandbox organization and click Create.
    Connection Display Name dialog box.
  5. Enter your NTO sandbox org’s username and password and click Log In to Sandbox.
    Salesforce sandbox org’s login page.
  6. Click Allow to grant MuleSoft Composer the permissions to access the identity URL service, manage user data via APIs, and perform requests at any time. MuleSoft Composer automatically tests the connection. If no error message appears, you have a successful connection, and the first step (trigger) of the flow appears.
    Salesforce Allow Access page with Allow button.
  7. Click in the Choose an event that starts this flow field and select New or updated record.
  8. In the Object Type field, enter Account.
    Step 1 of flow with trigger event on new or updated Account object and Select Fields button.
  9. Click the expand icon in the Sample Output section. The fields and associated sample values from an account in the NTO org appear. This confirms you’re connected to the correct system and lets you know the structure of the data that is available in later steps of your flow.
    Sample Output section in Step 1 of flow showing account ID and account name.

Note: After you’ve created and configured a trigger, MuleSoft Composer automatically generates a name for it. If this name isn’t sufficient for your business needs, click the pencil icon next to it, give it a new name, and then click Save.

Select Fields for an Object

By default, all fields associated with the object in the trigger are returned to the flow. If you need to narrow down to specific fields of the object, you can apply a filter. 

Follow these steps to select fields for an object. 

  1. Click Select Fields.
    Step 1 of flow with trigger event on new or updated Account object and Select Fields button.
  2. In the search field, enter a keyword for the field you want to search, select the relevant field that appears, and then click Add.
    Select Fields dialog box with selected fields such as billing city and billing country.
  3. Click the X icon to clear the keyword from the search field.
  4. Repeat steps 2 and 3 for the remaining fields you want to select.
  5. When done with selecting all desired fields, click Add.

Use a Scheduler as a Trigger

If your business requirements demand it, you can use a scheduler to run a flow at a regular time interval. With the scheduler, you can trigger your flow every 15, 30, 45 minutes, and so on up to every 30 days.

Follow these steps to add a scheduler as a trigger to a flow.

  1. On the What Should Start This Flow dialog box, scroll down and click Scheduler.
  2. Select a time interval of your choice.
    Step 1 of flow with scheduler to start flow every hour.

At runtime, the scheduler starts running at the specified time interval. For example, you schedule your flow to run every 1 hour and you activate it at 8 AM on Monday. The flow starts running at 9 AM on Monday and continues every 1 hour. It continues to run until deactivated.

Add Action Steps to a Flow

Recall from MuleSoft Composer Basics that a flow is a sequence of steps that you assemble and configure to integrate systems and data. After you’ve added a trigger to your flow, the next step is to add action steps to the flow.

Let’s say you want to create a flow that syncs Salesforce accounts to Slack notifications. The flow must perform the following tasks. 

  1. Find any new or updated account in the NTO org.
  2. Send a notification to the Slack sales-leads channel.

Earlier in this unit, you learned to create a flow that starts when an account is created or updated in the NTO org. 

Now, let’s add an action step for sending notifications to Slack to this flow. Assume an NTO workspace and sales-leads channel have been created in Slack. To learn how to perform this task, take Slack Automation with MuleSoft Composer

Here’s how to create and configure an action step that sends a notification to the sales-leads channel.

  1. Click the plus icon to add a step after the trigger.
  2. Click Slack.
  3. Name the connection NTO Slack and click Create.
  4. Select NTO from the Slack workspace picklist.
  5. Click Allow to grant MuleSoft Composer the permissions to the NTO workspace. The MuleSoft Platform app is automatically added to the NTO Slack workspace, and the second step of the flow appears.
  6. Click in the Action field and select Post message to channel.
  7. In the Channel Name field, click the search icon, select Pick from List, and then select sales-leads.
  8. Click in the Message field and then click Custom Expression. The Custom Expression Editor appears.
  9. Click the Data tab, and then click Account Name from step 1 of the flow. Account Name appears in the Message field.
  10. In the Message field, enter: has been created or updated.
  11. Click Apply.
    Custom Expression Editor dialog box.
  12. Save the flow. Your entire flow should look like this.
    Step 1 of flow with trigger event on new or updated Account object and Select Fields button.Step 2 of flow showing post message to the sales-leads Slack channel.

Similar to a trigger, if the auto-generated name of an action step doesn’t meet your business needs, click the pencil icon next to it, give it a new name, and then click Save.

Exit a Flow

After you’ve created and configured a flow, you can exit it.

Follow these steps to exit a flow.

  1. Click the Composer Flows tab.
    MuleSoft icon and Composer Flows tab.
  2. If there are changes, then you’re prompted to save your work.
    Save changes dialog box with Save button.
  3. Click Save to save your flow.

Nice job! You’ve taken the first steps to create an integration flow using MuleSoft Composer. In the next unit, you learn how to map and retrieve data in the action steps of your flow.

Resources 

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback