Serverless Integration With Salesforce Using Kumologica
In this article, we will discuss low code, serverless, and real-time integration of a Salesforce outbound message with the target system using Kumologica.
Join the DZone community and get the full member experience.Join For Free
Salesforce is a popular CRM platform used by many enterprises. Integration of salesforce modules with different enterprise systems is very common. There are multiple ways by which salesforce objects can be integrated.
- SOQL query (Pulling the records)
- Platform Events (Pushing the events)
- CDC (Pushing the events)
- OutboundMessages (Pushing the events using webhooks)
Most of the real-time integrations with Salesforce work with PE (platform events), CDC, and OutboundMessages. There are also solutions where SOQL query works in complementary with PE, CDC, or OutboundMessages (Webhooks).
In this article, we will see how to send a Salesforce outbound message to the target systems using Kumologica flow that runs on serverless infrastructure. For those who are new to Kumologica, I would recommend going through our articles and youtube videos to get an insight.
Before we begin, let’s try to understand the working mechanism behind outbound messages in Salesforce.
OutboundMessages in salesforce are part of the workflow in salesforce. The underlying mechanism is based on webhook notification. Whenever a change happens in any salesforce objects, the associated outbound message is triggered by the workflow rule. The change can be an insert, update, or deletion of a salesforce object. The outbound message is configured with an HTTP post endpoint. Salesforce outbound message will invoke the endpoint to send a SOAP payload having the appropriate object fields (eg: Case, Contact, etc).
In this use case, we will be using the Salesforce contact object. Whenever a new contact is created in Salesforce an event is triggered which will be sent to the target system by Kumologica flow. Here the target system is the Amazon SQS queue.
The HTTP endpoint implementation will be done using the Kumologica designer. The Kumologica flow will be then deployed on AWS Lambda. After the deployment, we will copy the gateway endpoint which is then configured on the outboundMessage section in Salesforce.
- Salesforce account—For configuring the outbound message connecting contact module.
- Kumologica Designer—Download the designer for building the flow.
- AWS account—For running the Kumologica flow as lambda and for hosting the SQS queue.
We will be creating a ContactInboundService flow in Kumologica designer. This flow will expose the endpoint on the resource path
- Open the Kumologica Designer, click the Home button and choose: Create New Kumologica Project.
- Enter name (for example ContactInboundService), select directory for the project.
- Press the Create Button.
- Drag and drop EventListener node to the canvas the provide the following configuration.
Add a Logger node and wire with the EventListener node. Provide the following message.
Drag and drop the Set-Property node to the canvas and wire it with the logger node. Provide the following configuration.
J is the JSONata expression to be selected from the drop-down.
- Add the SQS node to canvas and wire it with the Set-Property node. Provide the following configuration.
Note: Ensure that you have an SQS queue created in your AWS account and you have the queue URL for configuring in the SQS node. Refer here.
- Add EventListener End node and wire with the SQS node. Provide the following configuration.
- Select the AWS icon on the right-hand side vertical tab of Kumologica designer, select your AWS Profile.
Note: If you haven’t mapped your local AWS profile with the designer then you may follow the below video to configure it.
- Click Connect. If successfully connected will show the rest of the configuration options.
- Set the Memory to 512mb and Timeout as 20 seconds.
- Go to the Trigger section under the cloud tab and select the Amazon API Gateway trigger.
Post successful deployment copy the endpoint URL from the Kumologica terminal. We will need this endpoint for configuring the OutboundMessage in Salesforce.
We have the Kumologica flow deployed and got the HTTP endpoint. Let's now configure the endpoint as an OutboundMessage webhook in Salesforce.
Configuring OutboundMessage in Salesforce
- Go to your Salesforce Account and search for Outbound Messages.
- On the Outbound Message screen, create a “New Outbound Message.”
- Select the object as “Contact” and click Next. Provide the following details.
- Click Save. Now you have created an Outbound Message.
- Let’s map the Outbound Message to the workflow rule.
The above rule configuration ensures that anytime a contact is created with the description that starts with “ABC” the workflow will invoke the Outbound Message.
Now we will map the “ContactWebhook” OutboundMessage we have created in the earlier step to this workflow rule we are configuring.
- From “Add Workflow Action” click on “Select Existing Action”.
- From the type select “OutboundMessage”.
- Now you will see the “ContactWebhook” in the Available Actions list. Add it and Save.
- Now we are ready to rock 'n roll.
- Go to the Salesforce contact module and create a new contact.
- Go to the AWS account and look into the SQS queue. You will observe that a SOAP message is now available in the queue.
Opinions expressed by DZone contributors are their own.