If you have not explored Salesforce Event Relay feature yet, then this is time to explore it. Last year I was exploring options to integrate Salesforce with Amazon Web Services (AWS) and I was excited to know the General Availability of Salesforce Event Relay.
With Event Relay, you can integrate your Salesforce application with Amazon Web Services (AWS) natively and without writing a single line of code. You can use power of Salesforce Lightning Flow, Platform Event and Event Relay to integrate Salesforce with AWS.
Event Relay connects Salesforce Event Framework (Platform Event, CDC) to AWS EventBridge. EventBridge is a serverless event bus that works very similar to Salesforce Platform Event. Different AWS Service can subscribe to EventBridge and get the notification message in near real-time. Please refer Amazon documentation for EventBridge.
You can consider Event Relay as an out of the box client that subscribes to Salesforce Event Bus and sends the event messages to AWS Event Bridge. It takes care of all the complexities for this integration, and we can focus on business logics that is needed to publish and consume the events. You can refer this Salesforce link to get more details of Event Relay
As we know Event-Driven Architectures are one of the best integration design patterns. It is scalable and works in near real-time and Salesforce is simplifying this design pattern day by day by adding more capabilities.
We would explore an integration design that uses Event Relay using a sample business requirement and potential solution using Salesforce Event Relay.
Business Requirement
Well, we got a new integration requirement, that requires us to publish Lead details to multiple systems, once the status of Lead record is updated as “Qualified”. For this requirement, Salesforce Sales Cloud is source of truth for Lead record and when status is updated, we have to send lead details to several other applications including few applications hosted on Amazon Web Services (AWS) platform.
Integration Solution
Well, this may not be only possible solution to meet this requirement, but to understand the Salesforce Event Relay feature, I am going to discuss the solution that we implemented in one of our project. I am going to provide only high level solution and you can always refer Salesforce documentation to get more details.
Base Configuration for Event Relays
- Create a new Platform Event to hold attributes of Lead object that we would like to Integrate
- Create a new Salesforce Lightning Flow, a record triggered flow, that publishes a Salesforce Platform Event when the lead status is updated as “Qualified”
- Configure Salesforce changes for setting-up Event Relay
- Create a named credential: Named Credential would contain AWS account information and AWS region. URL of named credential should in form of arn:aws:US-EAST-N:111111111111. You need to update region and account id accordingly. I still used Legacy Named Credential for this requirement
- Create an Event Channel and add Platform Event to Event Channel as Channel Member. Event Relay uses event channel. We can add multiple platform events in single event channel as channel member(s). All events from an Event Channel can be relayed together. You have to use tooling API to create event channel and channel members. You can use postman or similar tool
// sample JSON to create Event Channel
{
"FullName": "CRMView_Demo_Channel__chn",
"Metadata": {
"channelType": "event",
"label": "CRM View Demo"
}
}
// sample JSON to create Event Channel Member
{
"FullName": "CRMView_Demo_Channel_chn_Lead_Event_e",
"Metadata": {
"eventChannel": "CRMView_Demo_Channel__chn",
"selectedEntity": "Lead_Event__e",
"urls": null
}
}
Event Relays Configuration
We can launch new Event Relays wizard from Setup. Go to Setup and type Event Relay in Quick Find and then create a new Event Relay. It would open multi-step wizard to setup a new Event Relay
Step 1: Provide the label and name for Event Relay
Step 2: Select a Named Credential
Use the name credentials that we created as part of base configuration
Step 3: Select a Channel
Use the Event Channel that you created and added platform event as member of event channel
Step 4: Event Relay Error Recovery Option
See how it should react after recovering from an error like connectivity or something similar
Step 5: Summary to validate
Step 6: Confirmation
You would get confirmation with the configuration you selected. Status would be stopped by default. Also Platform Event Source Name would be blank, and it may take few minutes to get it updated. If it does not get updated after few minutes, then re-validates all the configuration and connectivity details. Refer the below images for before and after Partner Event Source Name is updated
Configuration at AWS EventBridge
Salesforce creates Partner Event Source (as the name populated above image) in pending status and we have to associate Partner Event Source with Event Bus.
- Login to AWS Console and navigate to Amazon EventBridge from Services
- Navigate to Integration >> Partner Event Source and find the Partner Event Source from the list. It should be in Pending Status as given in below image
- Select the Event Source and click Associate and the status would get updated as Active
Start Event Relay and Validate
Well, we are done with the whole configuration needed to setup an Integration between Salesforce and AWS using AWS EventBridge and Salesforce Event Relay. Now we can go back to Salesforce and start the Event Relay.
- Edit the Event Relay record in Salesforce and update the state to Run. It may take few seconds and status would be updated to Running
- Identify a test lead record and update status to “Qualified”. This would trigger the Salesforce Lightning Flow and publish and event to Platform Event
- You can see the Event Relay Last Relayed would be updated the current date time. You can also verify by creating a rule in AWS
Now we are ready with our integration. We can configure an EventBridge rule and AWS Service can subscribe to process the events published from Salesforce.