Learn how easy it is to use App Connect to connect Salesforce to IBM Event Streams so that every time a new contact is created in Salesforce, Event Streams sends a message to IBM Cloud Functions.

IBM Event Streams (formerly IBM Message Hub) is a fully managed, cloud-based messaging service that’s available through IBM Cloud (formerly Bluemix). And IBM Cloud Functions (which used to be known as IBM OpenWhisk) is a Function-as-a-Service (FaaS) platform, also available through IBM Cloud, that calls functions in response to incoming events – events like messages from Event Streams. Cloud Functions can connect to a range of event consumers, so you might use it with a cognitive service like IBM Watson, for example, to analyze data as soon as you receive it. So you can imagine the possibilities when you use App Connect with Event Streams and Cloud Functions to route or analyze the data from your favorite apps.

This tutorial shows you how to create your flow in App Connect, configure Event Streams and Cloud Functions, and test that your flow is working.

First, find or create everything you need:

Next, create your flow:

(App Connect automatically saves your changes as you go. If you move away from the flow at any point, the flow is saved as a draft flow that you can come back to later.)

  1. Log in to App Connect.
  2. From the Dashboard, click New > Event-driven flow.
  3. Enter a name that identifies the purpose of your flow, for example: Salesforce contacts to Cloud Functions.
  4. Select Salesforce as your first application (source), then select Contacts > New contact as the Salesforce event that’ll trigger the action in Event Streams.
  5. If you haven’t already connected to your Salesforce account, click Connect and follow the instructions to allow App Connect to access your Salesforce account.
  6. Select IBM Event Streams as your second application (target), then select Send message as the action.
  7. If you haven’t already connected to your Event Streams account, click Connect to connect now. You can find the required credentials on the Service credentials page of your Event Streams service in IBM Cloud. Click View credentials and copy the whole block of code into App Connect.

    Tip: To copy the credentials, click the copy icon Icon that copies your credentials.

  8. Set the Topic field to Demo.
  9. In the Payload field, type Contact created: leaving a space after it. Then click the Insert a reference icon , select the First name, then leave a space. Repeat to add the Last name field. These fields contain the data that you want to send in the message to Cloud Functions. Screenshot that shows the completed Payload field, as described in the instructions.
  10. From the banner, open the options menu [⋮] and click Start flow. Then click Dashboard to exit the flow. You can now see the flow on your Dashboard; as long as it says “Running”, it’s listening for your event – a new contact being created in Salesforce.

Now, configure Event Streams and Cloud Functions:

  1. On the Manage page of your Event Streams service in IBM Cloud, click Create topic The Create topic icon in the Event Streams service.
  2. Set the topic name to Demo, then click Create topic.
  3. Go to Cloud Functions in IBM Cloud (https://console.bluemix.net/openwhisk) and click Start Creating.
  4. Click Create Action, name the action Salesforce event, then click Create.
  5. Click Open in Develop View. (Hint: You might need to close the message that says “Your Action was created” to see the button.)
  6. Edit the return parameter in the code to say { "message": "Cloud Functions event: " + params.messages[0].value } Screenshot of code in Cloud Functions
  7. Click Make It Live, then click Automate this Action.
  8. Click the MESSAGING tile, then click NEW TRIGGER.
  9. Name the configuration Demo topic messages.
  10. Next, you’ll configure the Event Streams service to use as the trigger for Cloud Functions. If you see a field called Select an existing IBM Cloud service instance, you can either select an existing Event Streams service or choose “I’d rather Start from Scratch”. Alternatively, you might just see a collection of fields to complete.
  11. Copy the relevant information for the kafka_brokers_sasl, user, password, and kafka_admin_url fields from the Service credentials page of your Event Streams instance in IBM Cloud. Screenshot of the Event Streams Service credentials page in IBM Cloud
  12. Set the topic to Demo.
  13. Set the fields isJSONData, isBinaryKey, and isBinaryValue to false (with a lower case “f”).
  14. Click Save Configuration.
  15. Click Next, then This Looks Good, then Save Rule.
  16. Click View Activity to open the Cloud Functions Monitor page.

Finally, test your flow:

  1. Log in to your Salesforce Developer Edition account and create a new contact.
  2. Go back to your Cloud Functions Monitor page and check the Activity log. (You might need to click Refresh.) You should see a message with the name of the contact that you just created in Salesforce. Screenshot of Cloud Functions Activity Log, showing the contact you added to Salesforce

You’ve created a flow that automatically uses Event Streams to send a message to Cloud Functions every time a new contact is created in Salesforce.

If you can’t find what you want, or have comments about this tutorial, please either add comments to the bottom of this page or .

Join The Discussion

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