Learn how to use IBM App Connect on IBM Cloud to create an event-driven flow such that when a new contact is created in Salesforce, a “Getting Started” document is automatically downloaded from IBM Cloud Object Storage and then sent to a specific folder in Dropbox. This tutorial demonstrates how you can easily create a flow by specifying information in a simple manner.

IBM’s Cloud Object Storage (COS) S3 is ideal for holding large amounts of colder production data, such as backups and archives, and very large individual files, such as video files, image files, and genomic data. IBM’s Cloud Object Storage S3 is a reliable, durable, and resilient object storage.

Note: This document assumes that you have signed up for free or trial accounts for accounts with Salesforce, IBM Cloud Object Storage, and Google, or that you have business accounts.

Scenario:

Say you are using Salesforce to manage customers and use IBM Cloud Storage to store some related documents. You also use Dropbox to share files in folders specific to users. When a new contact is created, you want to create a folder on your Dropbox and as a first step, send a “Getting Started” document to this contact. The “Getting Started” manual is a PDF file stored in your IBM Cloud Object Storage account.

Event-Driven flow to download a document from IBM Cloud Object Storage when a new contact is created in Salesforce and upload that document to Dropbox. (Click image to view full size.)

First, find or create everything you need:

  1. An App Connect subscription.
  2. Obtain account details for connecting App Connect to your applications (If you haven’t already connected App Connect to your 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 an IBM Cloud Object Storage account, you need the following values that can get from the “Endpoint” and “Service Credentials” pages in the side navigation of your IBM Cloud Object Storage dashboard:
      Endpoint URL        COS Endpoint / PUBLIC or PRIVATE URL value for your region; for example, s3-api.us-geo.objectstorage.softlayer.net (PUBLIC for us-geo region)
      Secret Access Key   COS Service credentials / View credential (with HMAC) / cos_hmac_keys/ secret_access_key
      Access Key ID       COS Service credentials / View credential (with HMAC) / cos_hmac_keys / access_key_id
      Region              COS Endpoint / Select Location value; for example, us-geo
      

      Note: To get a Secret Access key and Access Key ID, you need to have a credential created with the option to generate HMAC credentials. (When adding a new credential, specify {"HMAC":true} in the field “Add Inline Configuration Parameters (Optional):”. For more information, see doc link after examples).

      For example:

      Credential with HMAC keys on IBM Cloud Object Storage console. (Click image to view full size.)

      In App Connect, when creating a connection to IBM Cloud Object Storage:

      Endpoint URL        s3-api.us-geo.objectstorage.softlayer.net
      Secret Access Key   12e3f4b56b780503172f70fdb2d1605a5dcfaf834d896c42
      Access Key ID       1234eeaa5ce67e2a89f52bc33f6a172d
      Region              us-geo
      

      For information about determining these values and about generating HMAC credentials, see “Service credentials” in IBM Cloud Docs / Cloud Object Storage.

    • You can create a connection to Dropbox either using a Dropbox user ID and password or using a Google account.

Next, create your flow:

  1. Log in to App Connect Designer; for example, launch App Connect through your IBM Cloud dashboard.
  2. 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.

  3. Enter a name that identifies the purpose of your flow; for example: Share Document with Salesforce Contact
  4. Select Salesforce > New contact as the event that is to trigger the flow.
  5. Click the (+) and then scroll down to IBM Cloud Object Storage S3.
  6. Select IBM Cloud Object Storage S3 > Download object as the action that App Connect should use to download the “Getting Started” document.
    IBM Cloud Object Storage / Download object action. (Click image to view full size.)
  7. If you have not connected App Connect to IBM Cloud Object Storage, click Connect and then complete and submit the request using the account details that you obtained above.
    Specify details to connect to IBM Cloud Object Storage S3. (Click image to view full size.)
  8. Select the “Bucket” where your document is stored on IBM Cloud Storage.
    Download the object from IBM Cloud Object Storage (Click image to view full size.)
  9. Select the Type of file as “binary” since you are downloading a PDF document
  10. Set the Object name as the name of your “Getting_Started” manual.
  11. For the next node, click the (+) after the IBM Cloud Object Storage S3 node and scroll down to the Dropbox. You next create a folder for the new Salesforce contact.
  12. Select Dropbox > Create folder as the action that App Connect should use to create a folder.
    Create a folder on Dropbox (Click image to view full size.)
  13. Set the “Path” field to uniquely identify a folder for the contact. As an example, I am creating a folder with the contact’s first and last name separated by an underscore. The value is mapped from the Salesforce node’s New contact into the Path field of Dropbox node’s Create folder
  14. Next, create the “Getting Started” manual that was downloaded from IBM Cloud Object Storage S3 in this folder on Dropbox
  15. Click the (+) after the Dropbox Create folder node, scroll down and select Dropbox.
  16. This time, select Dropbox > Create file as the action that App Connect should use to create a file.
  17. Set the following values for the fields in your Dropbox > Create file
    • For the “Path”, map the first and last name, separated by an underscore, to the Salesforce node’s New contact
    • The “File content” is mapped to the Object content from the IBM Cloud Object Storage S3 nodes’s Download object.
    • Set “Auto rename” to false since this is the first time the file is being created.
      Set “Mute” to false.
    • Set the “FileName” as the name of your “Getting Started” manual. In this example, I have used the name “Getting_Started.pdf”
    • Set “Is text” to false, since this is a pdf document that is getting uploaded.
    Create a file in the folder created on Dropbox. (Click image to view full size.)
  18. 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.
    The flow tile on the Dashboard, showing that the flow is running and listening for events. (Click image to view full size.)

Finally,test your flow:

  1. Log in to Salesforce using the account that you configured in App Connect.
  2. Create a new Salesforce contact and save the contact.
    Creating a new contact in Salesforce. (Click image to view full size.)
  3. After a short while, check your Dropbox for a new folder and document.
    Document created in the folder on Dropbox. (Click image to view full size.)
  4. Examine the App Connect Dashboard. If the flow ran successfully, the flow tile shows a green tick
Flow tile showing the last successful run of the flow. (Click image to view full size.)

Congratulations, you have created a flow that is triggered when a new contact is added to Salesforce, it downloads a document from IBM Cloud Object Storage S3, creates a folder on Dropbox and places the downloaded document in the folder.

2 comments on"Downloading a file from IBM Cloud Object Storage to a Dropbox folder"

  1. Kommina Swathi Mukeswari July 27, 2018

    Could you provide the sample code for upload object in cloud object storage from drop box using nodejs

    • Ian_Larner July 30, 2018

      Hi Kommina,
      Thanks for the request. We can provide an example of retrieving files from Dropbox and uploading to cloud object storage with App Connect on IBM Cloud. It does not need any coding (such as using nodejs).

      Can you provide more about the use case that you are interested in? You can either reply here or send me an email.

      Regards,
      Ian
      ian_larner@uk.ibm.com

Join The Discussion

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