Skip to main content

Design and Test a Flow

Learning Objectives

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

  • Design a flow to automatically sync data from Google Sheets to Salesforce to Slack.
  • Test your flow to ensure it syncs data as expected.

In this unit, you first learn how to use MuleSoft Composer to create a flow that automatically syncs leads in Google Sheets with leads in Salesforce and notifications in Slack. Then, you test your flow to ensure it syncs data as expected.

By default, MuleSoft Composer validates your work and provides contextual in-app help every step of the way. For example, when you add a connection to a system, MuleSoft Composer tests the connection to make sure it works before you can proceed to the next step. Also, to simplify building your flows, MuleSoft Composer prompts you to complete required fields within each step.

As a best practice, when building a flow, add a few steps and test iteratively until you complete the flow. 

Note

If you have a large integration task, it’s recommended that you break up the task into manageable, bite-sized chunks, and then create a flow for each chunk. This enables you to more easily and quickly build, test, and run your flows to accomplish the task.

Take a look at this video demonstration showing how to connect Google Sheets to Salesforce to Slack using MuleSoft Composer.

Design a Flow

Now you’re ready to design an integration flow that syncs leads in Google Sheets with leads in Salesforce and notifications in Slack. 

Note

When designing a flow, you usually work with objects and associated fields of the systems you need to integrate. MuleSoft Composer makes it easy for you to find objects and fields with the smart search feature. Type a few leading characters of the object or field you’re looking for in a step of a flow and then select the relevant value that appears.

Follow these steps to design a flow.

Launch MuleSoft Composer from the NTO org.

  1. Log in to your NTO org using your username and password.
  2. From the App Launcher, enter Composer and select MuleSoft Composer.

Create a new flow.

  1. Click Create New Flow.
  2. Click the pencil icon next to the default flow name.
  3. Name the flow Sync Leads - GSheets to Salesforce to Slack and click Save.

Create the trigger for the flow using the Marketing Leads spreadsheet.

  1. Click Google Sheets.
  2. Click Add new Google Sheets connection.
    Note: If this is your first Google Sheets connection, this option doesn’t appear. Go to the next step.
  3. Name the connection NTO Google Sheets and click Create.
  4. Select the Google account that owns the Marketing Leads spreadsheet.
  5. Select the permissions for MuleSoft Composer to see and download all your Google Drive files; see information about your Google Drive files; and see, edit, create, and delete all your Google Sheets spreadsheets.
  6. Click Continue to grant MuleSoft Composer the permissions into your Google account. 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.

Configure the trigger to start the flow every time a new lead is added to the Marketing Leads spreadsheet.

  1. Click in the Choose an event that starts this flow field and select New Row.
  2. In the Spreadsheet field, select Marketing Leads.
  3. In the Worksheet Name field, select Sheet1. Note that all fields are returned by default. You’ll use these fields to perform integration in subsequent steps of the flow.
  4. Click Save to save the flow.

Create the second step for the flow to get the NTO org leads.

  1. Click the plus icon to add a step.
  2. Click Salesforce.
  3. 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.
  4. Name the connection NTO sandbox org.
  5. Select the checkbox This is a sandbox organization and click Create.
    Note: If you use a developer org, skip selecting this checkbox and click Create.
  6. Enter your NTO sandbox org’s username and password and click Log In to Sandbox.
  7. 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 second step of the flow appears.

Configure the second step to get all NTO org leads that match the Marketing Leads spreadsheet lead.

  1. Click in the Action field and select Get records.
  2. In the Object Type field, enter Lead.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select First Name as the field, Equals as the operator, and First Name from step 1 of the flow.
  5. Click Add a condition.
  6. Select Last Name as the field, Equals as the operator, and Last Name from step 1 of the flow.
  7. Click Add a condition.
  8. Select Email as the field, Equals as the operator, and Email from step 1 of the flow.

Create and configure an If/Else block to check if a lead with the same first name, last name, and email as the Marketing Leads spreadsheet lead exists in the NTO org.

  1. Click the plus icon to add a step.
  2. Scroll down and click If/Else Block. The All conditions must be met (AND) condition is selected by default.
  3. Select List of Lead from step 2 of the flow as the field, and then select Is empty as the operator. If this condition is met, it means no corresponding lead exists in the NTO org. A new lead is created in the NTO org in the next step.

 Create the third step for the flow to sync leads in Google Sheets with leads in Sales Cloud.

  1. Click the plus icon within the If block to add a step.
  2. Click Salesforce.
  3. Click NTO sandbox org to connect to the NTO sandbox org.

Configure the third step to sync leads in Google Sheets with leads in Sales Cloud.

  1. Click in the Action field and select Create new record.
  2. In the Object Type field, enter Lead. The Last Name and Company fields automatically appear because they’re required fields.
  3. Click Add Fields, select First Name, Email, Phone, Country, Industry, and Lead Source, and then click Add.
  4. Map the columns in the Marketing Leads spreadsheet captured in step 1 of the flow to their corresponding Lead fields in Sales Cloud as follows.
  • First Name = First Name from step 1
  • Last Name = Last Name from step 1
  • Email = Email from step 1
  • Phone = Phone from step 1
  • Company = Company from step 1
  • Country = Country from step 1
  • Industry = Industry from step 1
  • Lead Source = Lead Source from step 1

Create the fourth step to sync Google Sheets leads with Slack notifications.

  1. Click the plus icon within the If block to add a step.
  2. Click Slack.
  3. Click Add new Slack connection.
    Note: If this is your first Slack connection, this option doesn’t appear. Go to the next step.
  4. Name the connection NTO Slack and click Create.
  5. Select NTO from the Slack workspace picklist.
  6. Click Allow to grant MuleSoft Composer the permissions to view content and info about channels and conversations, view content and info about your workspace, and perform actions in channels and conversations in the NTO workspace. The MuleSoft Platform app is automatically added to the NTO Slack workspace, and the fourth step of the flow appears.

Configure the fourth step to notify the sales-leads channel of new leads.

  1. Click in the Action field and select Post message to channel.
  2. In the Channel Name field, click the search picklist, select Pick from List, and then select sales-leads.
  3. Click in the Message field and then click Custom Expression. The Custom Expression Editor appears. You use this Custom Expression Editor to configure a message that has both dynamic field values from the preceding steps of a flow and static text that you enter.
  4. In the Message field, enter *New lead:*. This uses Slack’s support for the Markdown syntax to turn *New lead:* into New lead: in Slack.
  5. Insert a space and select First Name from step 1.
  6. Insert another space and select Last Name from step 1.
  7. Enter , and select Email from step 1.
  8. Enter , and select Phone from step 1.
  9. Click Apply.
  10. Leave the Bot Name and Bot Icon URL blank. By default, MuleSoft Composer uses the MuleSoft Platform Slack app to communicate with Slack.
  11. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new row in the Marketing Leads spreadsheet in Google Sheets as the trigger.Step 2 of flow to get all leads in NTO org.Step 2 of flow showing condition that all leads in NTO org must match the first name, last name, and email from the Marketing Leads row.If branch of flow showing condition to determine if list of lead is empty.Step 3 of flow within If branch to create a lead in the NTO org with company, last name, and country in the Marketing Leads spreadsheet.Rest of step 3 of flow within If branch to create a lead in the NTO org with email, first name, industry, lead source, and phone in the Marketing Leads spreadsheet.Step 4 of flow within If branch posting message to sales-leads channel in Slack.

Next, you learn how to test your flow. 

Test a Flow

After you’ve designed your flow, you need to test it from end to end to ensure it syncs data as expected. In general, you have up to 10 minutes to complete a test. When the test completes or 10 minutes have passed, the test stops. As a best practice, you should get all required applications and data ready for the test before starting it.

In this use case, when a lead is created in the Marketing Leads spreadsheet, it triggers the flow. First, be prepared to enter a test lead in the spreadsheet. 

Next, if the lead doesn’t exist in Sales Cloud, get ready to verify that a corresponding lead is created in Sales Cloud and that a message about the lead shows up in the sales-lead channel in Slack. 

Finally, if the lead exists in Sales Cloud, get ready to verify that no corresponding lead is created in Sales Cloud and no notification appears in Slack.

Follow these steps to test a flow.

  1. In the Sync Leads - GSheets to Salesforce to Slack flow, click Test. The flow goes into a read-only mode.
    Note: While the test is running, if for some reason you want to stop it, click Stop Test
  2. Open the Marketing Leads spreadsheet and enter a new lead with the following values.
    • First Name: Jane
    • Last Name: Doe
    • Email: jane.doe@acme.com
    • Phone: 212-333-4444
    • Company: ACME
    • Country: US
    • Industry: Finance
    • Lead Source: Web
  3. Go back to your flow and wait for the test to complete. If every step of the flow shows a green check mark, this indicates the flow ran successfully. Take a look at the Test Output section and see the record values you entered for the test.
    Tested flow showing a green check mark on step 1.Tested flow showing a green check mark on step 2.Tested flow showing a green check mark on step 3 in If branch.Tested flow showing rest of step 3 in If branch.Tested flow showing a green check mark on step 4 in If branch.
  4. Log in to the NTO org using your username and password.
  5. In the App Launcher, enter Sales, and then select Sales to launch Sales Cloud.
  6. Click the Leads tab, select All Open Leads, and verify a corresponding lead has been created in Sales Cloud.
    NTO org’s Sales Cloud leads showing the lead from Google Sheets.
  7. Open your NTO Slack workspace and verify the lead notification appears in the sales-leads channel. Notice that because you used *New lead:* in your flow, it appears as New lead: in Slack.
    Slack sales-leads channel showing a message with lead data from Google Sheets.
  8. In the Sync Leads - GSheets to Salesforce to Slack flow, click Test again.
  9. In the Marketing Leads spreadsheet, copy and paste the same lead into the next row.
  10. Go back to your flow and wait for the test to complete. If the first two steps of the flow show a green check mark but the last two steps don't, this indicates the flow ran successfully. This is because the lead exists in Sales Cloud, and so the If block evaluated to false and its two associated steps weren't executed.
    Tested flow showing a green check mark on step 1.Tested flow showing a green check mark on step 2.Tested flow showing step 3 in If branch without any green check mark.Tested flow showing rest of step 3 in If branch.Tested flow showing step 4 in If branch without any green check mark.
  11. In the NTO org’s Sales Cloud, verify no new lead has been created.
  12. In your NTO Slack workspace, verify no new notification appears in the sales-leads channel.
  13. Repeat steps 1 through 12 to test another lead of your choice. Your flow should work as expected.

Good job! In the next unit, you learn how to activate, monitor, and troubleshoot your flow in the production environment.

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback