Learn how to use IBM App Connect on IBM Cloud to create an event-driven flow such that when a new lead is created in Salesforce, if App Connect finds that lead in the IBM Db2 database then it sends an email to the Salesforce lead owner giving them the Db2 history of the lead. This tutorial demonstrates how you can easily create a flow by specifying information in a simple manner.
IBM Db2 is a relational database management system (RDBMS) product that services as a key to solving the problems of information management.
You are a Sales LoB person who has been using Db2 to store details of all your prospects or leads with other customer data. Then you have decided to switch over to Salesforce as your Customer Relationship Management (CRM) system, and started using it to record all new leads.
When a new lead is created in Salesforce, you want the lead owner to be automatically notified if the lead exists in Db2. For this, you use App Connect to easily create an event-driven flow that is triggered when a new lead is created in Salesforce, and checks if the lead is an existing lead in the Db2 leads table, and if the lead does exist so sends an email to lead owner giving them the Db2 history of the lead.
First, find or create everything you need:
This document assumes that you have signed up for free or trial accounts with Salesforce and IBM Db2 database server, or that you have business accounts.
- An App Connect subscription.
- Obtain account details for connecting App Connect to your applications (if you haven’t already connected App Connect to these applications):
- For Salesforce, you need user ID and password credentials to connect. If you want to create a free Salesforce account to test out App Connect, make sure that you create a Developer account rather than a Trial account. For more information, see How to use IBM App Connect with Salesforce.
- To connect to IBM Db2, you need the Db2 database server host name, port, user ID, password, database name, schema name, and database manager authentication type. If you are not the owner or administrator of your Db2 instance, you can obtain this information from your Db2 administrator. You’ll also need to specify the name of the network (configured using the IBM Secure Gateway Client) for connecting to a Db2 server in a private network. If you’ve previously used the Secure Gateway Client to set up a network connection for an App Connect application that is on the same private network as the Db2 server, you can use this network connection with Db2. For more information about completing these connection fields, see How to use IBM App Connect with IBM Db2.
Important: Ensure that the Secure Gateway Client has been started. If you need to, you can start the Secure Gateway Client as described in Configuring a private network for App Connect Designer: Finally, start and configure the Secure Gateway Client.
You can connect to the IBM Db2 app either from the Applications tab on the Catalog page, or when you add the app to a flow. After you connect, the Db2 database objects, and applicable events and actions can be discovered.
- Immediately after you connect, rename your account with a meaningful name that helps you identify which schema the account relates to. You’ll find this useful if you’d like to access multiple schemas in your flows. You can rename an account only from the Applications tab on the Catalog page, and before it’s used in a flow.
- If you’d like to access multiple schemas in your flows, you’ll need to add an account for each schema whose objects you want to run operations on.
For information about renaming accounts and setting up multiple accounts, see FAQ: How do I configure App Connect to connect to my applications?
- The OAuth client ID, client secret, access token, and refresh token for your Gmail account. For more information about how to get the required values, see How to use IBM App Connect with Gmail.
Next, create your flow:
- Log in to App Connect Designer; for example, launch App Connect through your IBM Cloud dashboard.
- From the Dashboard, click New > Event-driven flow.
Complete the following steps. As you progress, App Connect automatically saves your changes. If you navigate away from the flow at any stage, the flow is saved as a draft flow that you can complete at another time.
- Enter a name that identifies the purpose of your flow; for example: Retrieve lead history from Db2 for each Salesforce lead
- Select Salesforce > New lead as the event that is to trigger the flow.
- Click the (+) and then scroll down to IBM Db2.
- Select IBM Db2 > Show More > Retrieve LEADS records as the action.
- Map the Retrieve LEADS where clause fields with the response from Salesforce lead object.
- Select the If(Conditional) node from Toolbox and use the count function to check the leads count on the response from Db2 Retrieve node
- Inside the IF flow node select Salesforce > Retrieve user to get the Lead Owner’s email address and map the User ID with Owner ID from salesforce New Lead response
- Use Gmail > Create Message to send an email to the lead owner along with the lead’s history
- From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow. Your flow is displayed on your Dashboard and is listening for your event – the addition of a new contact in Salesforce.
Finally,test your flow:
- Log in to Salesforce using the account that you configured in App Connect.
- Create a new Salesforce lead that already exists in your Db2 database, and then save the lead.
- After a short while, check your email inbox for a new email containing the history of the lead obtained from the Db2 database.
- Examine the App Connect Dashboard. If the flow ran successfully, the flow tile shows a green tick
Congratulations, you have created a flow that is triggered when a new lead is added to Salesforce, and retrieves the history of that lead from a leads table in IBM Db2, and then sends an email to the Lead owner with lead’s history.