Learn how to use IBM App Connect to create an event-driven flow that creates a lead in an on-premises sales system with a file-based interface whenever a lead is created in Salesforce.


Your company is starting to use Salesforce for its Sales reps to record customer leads that they find. In the past, all customer-related sales information has been stored in an on-premises custom sales application. The on-premises system still needs to have a record of all the leads found by the sales reps, but they don’t want to have to enter the data in both systems. In time, the Salesforce system will take over more and more of the on-premises application processing but for now, both applications need the lead information. Integrating these two systems requires a hybrid integration approach where some of the integration function runs in the cloud and some must run on premises. App Connect (through the beta Enterprise plan) provides exactly this capability, being able to split the integration seamlessly between the cloud and on-premises system, without the need to define special interfaces or expose the on-premises system directly to the public internet.

First, find or create everything you need:

  • A Salesforce business or Developer Edition account.
  • An IBM Cloud account with IBM App Connect service – Custom Enterprise, Cloud Connector, or Lite plans.
  • Either IBM App Connect Enterprise (ACE) v11 or IBM Integration Bus (IIB) v10 on your local machine.
    If you have not bought ACE v11 or IIB v10, you can develop and test integration solutions without charge by using the Developers Edition download.
  • If you want a bit more information before you start, you can read more about the Developer edition and how to use App Connect with Salesforce on the following pages:

    Import the enterprise integration project into ACE or IIB, and deploy the provided callable flow:

    All the resources required for this tutorial are provided in a project interchange file

    The steps are the same for ACE v11 Enterprise Toolkit and IIB v10 Integration Toolkit (the toolkit):

    1. Download the project export file by clicking the link above and saving the file to your local machine.
    2. Open the toolkit.
    3. Import the project into the toolkit and clicking File>Import. Expand IBM Integration, select Project Interchange, then select the downloaded file.

      A new project called AppConnectToIIB will appear in the toolkit. It contains one flow called WriteDataToFileAsXML:
      (Click image to view full size.)
      The flow is a simple callable flow that performs the following actions:

      • CallableInput registers the flow to be triggered when the endpoint WRITE_TO_FILE is called.
      • Construct XML Message converts the incoming data into an XML format, including the addition of a new unique identifier. It also constructs local environment overrides for the following file node to give the correct file and directory name.
      • Write to file appends the XML data directly to a file on the file system, using a new line for each new entry.
      • CallableReply sends a response to the original callable node request, including the unique identifier that’s created in the flow.

    4. The project contains a BAR file called AppConnectToIIB.bar, which contains the callable flow, ready to be deployed. Deploy the BAR file to the integration server you intend to use for the tutorial.

      In addition to the callable flow, the project includes the YAML configuration file for a flow exported from App Connect on IBM Cloud, called: Salesforce Lead to on-premises.yaml. This file will be used later to create a flow in App Connect on IBM Cloud.

    Configure the integration server to connect callable flows:

    1. Sign in to IBM App Connect on IBM Cloud.
    2. Open the hamburger menu, expand Manage, then select Callable flows.

      (Click image to view full size.)

    3. Click Connect callable flows, and then follow the instructions to configure the integration server to connect callable flows. (If the Connect callable flows button is disabled, click the Restart icon and, when it has restarted, refresh your browser window.) Use the same integration server where you deployed the BAR file containing the callable flow:

      (Click image to view full size.)

    4. When you’ve successfully tested the installed agent, refresh the Callable flows page and you’ll see the following callable flows listed: (Click image to view full size.)

    App Connect has now been fully configured. The on-premises integration server containing the callable flow has been registered with the system and can now be called from any IBM App Connect or IBM Integration Bus flow.

    In IBM App Connect on IBM Cloud, create and start a flow that will invoke the callable flow:

    Create the flow by importing the flow template that is in the imported toolkit project. The flow template is in the Other Resources folder and is called Salesforce Lead to on-premises.yaml. To import the flow:

    1. In IBM App Connect on IBM Cloud, return to the Dashboard and then click New > Import flow.
      (Click image to view full size.)
    2. Copy the YAML file from the toolkit into the App Connect dialog box, then click Import.

      The imported flow (Salesforce Lead to on-premises) will open in the IBM App Connect flow editor. It consists of three flow nodes:

      • Salesforce “New lead” event – The flow is triggered whenever a new lead is created in Salesforce.
      • Callable flow invoke action – When triggered, this first action calls the message flow that is running in ACE / IIB. The map in the action takes data from the trigger and writes it to the message tree sent to the callable flow. It also sets the file name and file directory that the flow will write the file to. These are currently set to /tmp and demo1.txt.

        If needed or wanted, change the file name and file directory to values that are valid for the machine that’s running ACE / IIB:
        (Click image to view full size.)

      • Salesforce “Update or create lead” action – The final action updates the new lead in Salesforce with data sent back from the called flow running in ACE / IIB. This data is mapped out of the returned local environment from the callable flow.
    3. When you’ve checked everything in the flow (including changing the directory and file name to valid values), open the options menu [⋮] in the banner and click Start flow. Then click Dashboard to exit the flow. The flow is now running and ready to be triggered by a new lead in Salesforce.

    Finally, test your flow:

    Create a new Salesforce lead:

    1. Log in to Salesforce using the account that’s connected to IBM App Connect.
    2. Create a new lead, specifying values for First Name, Last Name, Company, and Email; for example:
      (Click image to view full size.)

    3. Save the new lead.

    After a short while, an entry is written to the file specified in the Callable flow invoke action (original values /tmp and demo1.txt). The new lead description field is also be updated with the ID that’s generated in the callable flow:
    (Click image to view full size.)

    If the flow fails for any reason, any errors are displayed on the flow tile on the Dashboard.

    You’ve created a flow that’s triggered when a new Salesforce lead is created. The flow calls an on-premises integration flow that’s running in ACE / IIB. The on-premises flow transforms the message to an XML format, adds a unique identifier, and writes the data to a file ready for an on-premises application to process. It then sends a response back to the IBM App Connect flow containing the new ID. This ID is inserted into the Salesforce lead. The example shown uses Salesforce as the triggering application but could be changed to use any of the many application supported by IBM App Connect. The ACE / IIB part shows simple file processing but could make use of any of the array of transports and formats that ACE and IIB support. Here are some things you might like to try:

    • If you have IBM MQ available, try replacing the File Output node with an MQ Output node to send the message to a queue rather than to a file.
    • Try replacing Salesforce with a different application like Insightly.

    4 comments on"Syncing Salesforce leads with an on-premises sales system"

    1. Hi Team, In IBM Cloud Professional, the callable flow is not invoking on the given time and the time out occurs.. I had checked the onpremisis toolkit, still the request hasnt reached. …May i know the reason.


      • Ian_Larner April 15, 2020

        @Anil, Hi
        There was a problem with the switch server code. A fix has been pushed to production for UK and US regions of IBM Cloud. I’ve tested the flow with the Callable flow / Invoke action and it was successful, writing to the local file and returning data to update the Salesforce Lead description field.

        Regards, Ian

    2. pankaj gupta March 05, 2018

      Can an App connect version of the flow calls a cluster of IIB on premise editions and do load balance among them?

      • john reeve July 24, 2018

        Any number of IIB v10 or ACE v11 servers/executiongroups can be added to the App Connect instance. If you deployed the same callable flow to each of those servers then, when the App Connect flow calls it, the request will get routed to one of the versions of the flow. The routing is round robin and each additional call will get routed to a different server.

        Regards, John.

    Join The Discussion

    Your email address will not be published. Required fields are marked *