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 handwritten leads in Gmail with leads in Salesforce and notifications in Slack.
Prepare to Design a Flow
Recall from MuleSoft Composer Basics that a flow is a sequence of steps you assemble and configure to integrate systems and data. Before designing a flow, you should sketch out the steps of the flow using a flowchart. You can do this using paper and pencil to get a good idea of what your flow will look like.
Here’s an example flowchart showing all the steps of an integration flow for the NTO use case described in the previous unit.
Here’s a detailed description of the tasks and their associated flow components to create a flow for this NTO use case.
Task |
Flow Components |
---|---|
Find any new email with meetup in the subject and an attachment. |
Trigger from the Gmail account on new email with the filter meetup has:attachment. |
Invoke the Marketing Leads Extractor RPA process. |
Action step to invoke the Marketing Leads Extractor RPA process to extract leads from the attachment. |
Iterate over the list of extracted leads. |
For Each block to iterate over the list of leads returned from the RPA process. |
Fetch a corresponding lead, if any, from Sales Cloud. |
Action step to get all leads in Sales Cloud that have the same first name, last name, and email as the extracted lead. |
Determine if a corresponding lead exists in Sales Cloud. |
If/Else block within For Each block to check if the list of leads is empty and the extracted lead’s last name and company aren’t empty. Note: Last Name and Company are required fields of the Lead object in Sales Cloud. |
If a corresponding lead doesn’t exist:
|
In the If branch of the If/Else block:
|
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.
Take a look at this video demonstration showing how to sync handwritten leads in Gmail with leads in Salesforce and notifications in Slack using MuleSoft Composer and MuleSoft RPA.
Design a Flow
Now you’re ready to design an integration flow that uses the Marketing Leads Extractor MuleSoft RPA process to automatically sync handwritten leads in Gmail with leads in Sales Cloud and notifications in Slack.
Follow these steps to design a flow.
Launch MuleSoft Composer from the NTO org.
- Log in to your NTO org using your username and password.
- From the App Launcher, enter
Composer
and select MuleSoft Composer.
Create a new flow.
- Click Create New Flow.
- Click the pencil icon next to the default flow name.
- Name the flow
Sync Leads using MuleSoft RPA - Gmail to Salesforce to Slack
and click Save.
Create the trigger for the flow using an NTO Gmail connection.
- Click System Event, and then click Gmail.
- Click Add new Gmail connection.
Note: If this is your first Gmail connection, this option doesn’t appear. Go to the next step. - Name the connection
NTO Gmail
and click Create. - Click Sign in with Google.
- Select the Gmail account that marketing leads are sent.
- Select the permissions for MuleSoft Composer to view your email messages, search your email messages, view your settings, and send email on your behalf.
- Click Continue to grant MuleSoft Composer the permissions into your Gmail 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 email with meetup in the subject and an attachment is sent to a designated Gmail account.
- Click in the Choose an event that starts this flow field and select On New Email.
- In the Filter Criteria field, enter
meetup has:attachment
. This enables only emails with meetup in the subject and an attachment to start the flow. - Click Save to save the flow.
Create the second step for the flow using an NTO RPA connection.
- Click the plus icon to add a step.
- Click System Action, click MuleSoft RPA, and then click Add new MuleSoft RPA connection.
Note: If this is your first MuleSoft RPA connection, this option doesn’t appear. Go to the next step. - Name the connection
NTO RPA
. - In the RPA API URL field, copy and paste the RPA API URL from the text file obtained in unit 1.
- In the User API Key field, copy and paste the user API key from the same text file.
- Click Create. 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 invoke the Marketing Leads Extractor RPA process with the email subject as the input and the response from the RPA process as the output to be used in this flow.
- Click in the Action field and select Invoke RPA Process.
- In the RPA Process field, select Marketing Leads Extractor.
- In the Output field, select Use response in this flow.
- Click Select Optional Fields, select EmailSubject, and then click Apply.
- In the EmailSubject field, select Subject from step 1 of the flow.
Create and configure a For Each block to iterate over each item in the list of leads returned by the Marketing Leads Extractor in step 2 of the flow.
- Click the plus icon to add a step.
- Scroll down and select For Each.
- In the Input list field, select Result > Marketing Leads from step 2 of the flow.
Create the third step for the flow using an NTO sandbox org connection.
- Click the plus icon to add a step within the For Each block.
- Click System Action, click Salesforce, and then click Add new Salesforce connection.
Note: If this is your first Salesforce connection, this option doesn’t appear. Go to the next step. - Name the connection
NTO sandbox org
.
Note: Even though you’re logged in to your NTO org, you still need to create a connection to it to perform integration tasks. - 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. - Enter your NTO sandbox org’s username and password and click Log In to Sandbox.
- 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 third step of the flow appears.
Configure the third step to get all NTO org leads that match the first name, last name, and email of each extracted lead.
- Click in the Action field and select Get records.
- In the Object Type field, enter
Lead
. - In the Conditions to filter the objects picklist, select All conditions must be met (AND).
- Select First Name as the field, Equals as the operator, and Result > Marketing Leads > First Name from step 2 of the flow.
- Click Add a condition.
- Select Last Name as the field, Equals as the operator, and Result > Marketing Leads > Last Name from step 2 of the flow.
- Click Add a condition.
- Select Email as the field, Equals as the operator, and Result > Marketing Leads > E Mail from step 2 of the flow.
Create and configure an If/Else block to check if the list of leads is empty and the extracted lead’s last name and company aren’t empty.
- Click the plus icon to add a step.
- Scroll down and click If/Else Block. The All conditions must be met (AND) condition is selected by default.
- Select List of Lead from step 3 of the flow as the field and Is empty as the operator.
- Click Add a condition.
- Select Result > Marketing Leads > Last Name from step 2 of the flow as the field and Is not empty as the operator.
- Click Add a condition.
- Select Result > Marketing Leads > Company from step 2 of the flow as the field and Is not empty as the operator. If all three conditions are met, it means no corresponding lead exists in the NTO org and the extracted lead has both last name and company, which are required of any new lead by Sales Cloud. A new lead is then created in the NTO org in the next step.
Create the fourth step for the flow using the existing NTO sandbox org connection.
- Click the plus icon within the If branch of the If/Else block to add a step.
- Click System Action, click Salesforce, and then click NTO sandbox org.
Note: You reuse the existing NTO sandbox org connection.
Configure the fourth step to sync handwritten leads in Gmail with leads in Sales Cloud.
- Click in the Action field and select Create new record.
- In the Object Type field, enter
Lead
. The Company and Last Name fields are automatically selected because they’re required fields. - Click Select Optional Fields, select First Name, Email, Phone, and Description, and then click Apply.
- Map the Lead fields to their corresponding fields in the output returned by the Marketing Leads Extractor in step 2 of the flow as follows.
- Company = Result > Marketing Leads > Company
- Last Name = Result > Marketing Leads > Last Name
- Email = Result > Marketing Leads > E Mail
- First Name = Result > Marketing Leads > First Name
- Phone = Result > Marketing Leads > Phone
- Click in the Description 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 (also known as data pills) and static text that you enter.
- Configure the following message. Use the Data tab to select the relevant data pills.
This lead was generated from an email attachment sent to
To from step 1by
From from step 1with the subject line
Subject from step 1 - Click Apply.
Create the fifth step to sync handwritten Gmail leads with Slack notifications.
- Click the plus icon within the If block to add a step.
- Click System Action, click Slack, and then click Add new Slack connection.
Note: If this is your first Slack connection, this option doesn’t appear. Go to the next step. - Name the connection
NTO Slack
and click Create. - Select NTO from the Slack workspace picklist.
- 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 sales-leads channel of new leads.
- Click in the Action field and select Post message to channel.
- In the Channel Name field, click the search picklist, select Pick from List, and then select sales-leads.
- Click in the Message field, and then click Custom Expression. The Custom Expression Editor appears.
- 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. - Insert a space, enter
Name:
, and select Result > Marketing Leads > First Name from step 2. - Insert another space and select Result > Marketing Leads > Last Name from step 2.
- Enter
, Email:
, and select Result > Marketing Leads > E Mail from step 2. - Enter
, Phone:
, and select Result > Marketing Leads > Phone from step 2. - Enter
, Company:
, and select Result > Marketing Leads > Company from step 2. - Click Apply.
- Leave the Bot Name and Bot Icon URL blank. By default, MuleSoft Composer uses the MuleSoft Platform Slack app to communicate with Slack.
- Save the flow. Your entire flow should look like this.
Good job! In the next unit, you learn how to test your flow to ensure it works as expected.