Skip to main content

Design a Flow

Learning Objectives

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

  • Prepare to design a flow.
  • Design a flow to automatically sync data from ServiceNow to Salesforce to Slack.

In this unit, you first learn how to prepare to design your flow. Then, you learn how to use MuleSoft Composer to create a flow that automatically syncs incidents in ServiceNow with cases in Salesforce and notifications in Slack. 

Prepare to Design 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. Before designing a flow, you should map the tasks your flow must perform to their corresponding steps in the form of flow components. You can do this using paper and pencil so you can get a good idea of what your flow will look like.

Here’s an example of such mappings for the NTO use case described in the previous unit. 

Task Flow Components

Find any new or updated incident in ServiceNow.

Trigger from ServiceNow

Determine if a corresponding case exists in Service Cloud.

Action step to get all cases in Service Cloud that have the same ServiceNow number.

If a corresponding case doesn’t exist

If/Else block evaluating if the list of cases is empty with these action steps in the If branch:

  • Create a case with relevant incident details in Service Cloud.
  • Update the incident with the Salesforce Case ID in ServiceNow.
  • Notify the service-cases channel about the new case in Slack.

If a corresponding case exists

Action steps in the Else branch of the If/Else block:

  • Update the case with relevant incident details in Service Cloud.
  • Notify the service-cases channel about the updated case in Slack.

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 ServiceNow to Salesforce to Slack using MuleSoft Composer.

Design a Flow

Now you’re ready to design an integration flow that syncs incidents in ServiceNow with cases in Salesforce and notifications in Slack. 

Note

When designing a flow, you typically work with objects and 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 Service Cases - ServiceNow to Salesforce to Slack and click Save.

Create a trigger for the flow using the ServiceNow connection.

  1. Click ServiceNow.
  2. Click Add new ServiceNow connection.
    Note: If this is your first ServiceNow connection, this option doesn’t appear. Go to the next step.
  3. Using the text file that contains the ServiceNow connection parameter values, enter the required values with NTO ServiceNow as the connection display name, and then click Create. 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 an incident is created or updated in ServiceNow.

  1. Click in the Choose an event that starts this flow field and select New / Updated Record.
  2. In the Table Name field, enter incident.
  3. Click Save to save the flow.

Create the second step for the flow to get all cases in Salesforce that match the triggering incident.

  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 cases that match the incident.

  1. Click in the Action field and select Get records.
  2. In the Object Type field, enter Case.
  3. In the Conditions to filter the objects picklist, select All conditions must be met (AND).
  4. Select ServiceNow Incident ID as the field, Equals as the operator, and Number from step 1 of the flow.

Create and configure an If/Else block to evaluate whether the incident has a Salesforce Case ID.

  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 Case from step 2 of the flow as the field and Is empty as the operator. If this condition is met, it means the incident doesn’t have a corresponding case in Service Cloud. So the next three steps in the If branch (create Salesforce case, update ServiceNow incident, and send Slack message) are executed.

Create the third step for the flow within the If branch to create new cases.

  1. Click the plus icon to add a step within the If branch.
  2. Click Salesforce and then click NTO sandbox org.

Configure the third step to create new cases in Service Cloud.

  1. Click in the Action field and select Create new record.
  2. In the Object Type field, enter Case.
  3. Click Add Fields, select ServiceNow Incident ID, Status, and Subject, and then click Add.
  4. Map the Case fields in Service Cloud to their corresponding Incident fields in ServiceNow captured in step 1 of the flow as follows.
  • ServiceNow Incident ID = Number from step 1
  • Status = Click the search picklist, select Pick from List, and then select New
  • Subject = Short_description from step 1

Create the fourth step for the flow within the If branch to update incidents with their associated Salesforce Case IDs.

  1. Click the plus icon to add a step to the If branch.
  2. Click ServiceNow and then click NTO ServiceNow.

Configure the fourth step to update incidents with their associated Salesforce Case IDs.

  1. Click in the Action field and select Update Record.
  2. In the Table Name field, enter incident. The sys id is automatically selected because it’s a required field.
  3. Click Add Fields.
  4. In the search field, enter salesforce, select u salesforce case id, and then click Add.
  5. Map the Incident fields to the preceding steps of the flow as follows.
    • sys id = Sys_id from step 1
    • u salesforce case id = Id from step 3

Create the fifth step for the flow to sync ServiceNow incidents with Slack notifications.

  1. Click the plus icon within the If branch 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 fifth step of the flow appears.

Configure the fifth step to notify the service-cases channel of new incidents.

  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 service-cases.
  3. Click in the Message field and then click Custom Expression. The Custom Expression Editor opens. 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 incident:*. This uses Slack’s support for the Markdown syntax to turn *New incident:* into New incident: in Slack.
  5. Insert a space and select Number from step 1 of the flow.
  6. Enter , and select Short_description from step 1 of the flow.
  7. Click Apply.
  8. Leave the Bot Name and Bot Icon URL blank. By default, MuleSoft Composer uses the MuleSoft Platform Slack app to communicate with Slack.

Add an Else branch to the If/Else block of the flow to handle all incidents that have corresponding cases in Service Cloud.

  1. Click Add Else. Note that if the list of cases from the If branch isn’t empty, this means the incident has a corresponding case. So the next two steps in the Else branch (update Salesforce case and send Slack message) are executed.

Create the sixth step in the Else branch to update corresponding cases in Salesforce.

  1. Click the plus icon to add a step within the Else branch.
  2. Click Salesforce and then click NTO sandbox org.

Configure the sixth step to update corresponding cases in Salesforce.

  1. Click in the Action field and select Update record.
  2. In the Object Type field, enter Case. The Case ID is automatically selected because it’s a required field.
  3. Click Add Fields, select Status and Subject, and then click Add.
  4. In the Record section, map the Case fields to their associated Incident fields in step 1 of the flow as follows.
    • Case ID = U_salesforce_case_id from step 1
    • Status = Escalated
    • Subject = Short_description from step 1

Create the seventh step in the Else branch to sync ServiceNow incidents with Slack notifications.

  1. Click the plus icon within the Else branch to add a step.
  2. Click Slack and then click NTO Slack.

Configure the seventh step to notify the service-cases channel of updated incidents.

  1. Click in the Action field and select Post message to channel.
  2. In the Channel Name field, select service-cases.
  3. Click in the Message field and then click Custom Expression.
  4. In the Message field, enter *Updated incident:*. This turns *Updated incident:* into Updated incident: in Slack.
  5. Insert a space and select Number from step 1 of the flow.
  6. Enter , and select Short_description from step 1 of the flow.
  7. Click Apply.
  8. Leave the Bot Name and Bot Icon URL blank. By default, MuleSoft Composer uses the MuleSoft Platform Slack app to communicate with Slack.
  9. Save the flow. Your entire flow should look like this.
    Step 1 of flow showing a new or updated incident in ServiceNow as the trigger.Step 2 of flow to get all cases in NTO org that have the same ServiceNow number as the incident.If branch of flow showing condition to determine if list of cases is empty.Step 3 of flow within If branch to create a case in Service Cloud with number and short description of the incident and a status of new.Step 4 of flow within If branch updating the incident with a Salesforce Case ID.Step 5 of flow within If branch posting message to service-cases channel in Slack.Step 6 of flow within Else branch updating Service Cloud case with short description of the incident and a status of escalated.Step 7 of flow within Else branch posting message to service-cases channel in Slack.

Good job! In the next unit, you learn how to test your flow to ensure it works as expected.

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities