Sending an Outbound Message from a Flow in Salesforce

Sending an Outbound Message from a Flow in Salesforce

Big Idea or Enduring Question:

  • How to send an Outbound Message from Salesforce using Salesforce Flow?

Objectives:

After reading this blog, you’ll be able to:

  1. Understand what an outbound message is
  2. Understand the need for an outbound message when Salesforce Flow supports HTTPS callouts
  3. Configure an outbound message for a business use case
  4. And much more

Business Use case

Warren Mason, a System Administrator at Gurukul on Cloud (GoC), recently learned how to make HTTPS callouts via Salesforce Flow. To expand his knowledge, he now wants to understand and configure outbound messages to gain hands-on experience.

Since he doesn’t have a real business use case or endpoint URL, he decided to use Webhook.site, to get a unique, random URL for testing and debugging outbound messages.

He aims to send an outbound message whenever a lead is created, including the lead’s FirstName, LastName, Company, Email, and Phone.

What Is an Outbound Message in Salesforce?

An Outbound Message in Salesforce is a form of automated action that sends information to an external service in the form of a SOAP message over HTTP(S) when specific criteria are met. This allows for the integration of Salesforce data with external systems, enabling real-time updates and communication between Salesforce and other platforms.

Source – Salesforce Developer Site

Once you have configured outbound messaging, a message is sent to the designated endpoint URL whenever a triggering event occurs. This message includes the fields you selected during the creation of the outbound message. Upon receiving the message, the endpoint can process the contained information.

The Necessity of Outbound Messages in Salesforce Integration

While Salesforce Flow supports HTTPS callouts for direct communication with external systems, outbound messages offer a distinct advantage in specific scenarios. Outbound messages provide a reliable, asynchronous way to send data to external systems without requiring immediate processing. They ensure data delivery through the use of queues and retries, which can be crucial for maintaining data integrity and consistency in integrated systems. This reliability makes outbound messages particularly valuable in environments where immediate real-time processing is less critical or where external systems may not be immediately available to process incoming requests.

A single SOAP message can include up to 100 notifications. Each notification contains the object ID and a reference to the associated sObject data. If the information in the object changes after the notification is queued but before it’s sent, only the latest data is delivered and not the intermediate changes.

Prerequisite

Before we start configuring the outbound message, there are some prerequisites. First, you need an endpoint URL, and for this, we will use Webhook.site.

Second, the endpoint application’s server SSL/TLS can be configured to require client certificates (two-way SSL/TLS) to validate the identity of the Salesforce server when it acts as a client to your server. To do this, download the Salesforce client certificate from Salesforce. Import the downloaded certificate into your application server, and configure your application server to request the client certificate. The application server will then check that the certificate used in the SSL/TLS handshake matches the one you downloaded.

Introduction to Webhook.site

Webhook.site is an online service that provides a unique URL to capture and display HTTP requests sent to it. This tool is commonly used for testing and debugging webhooks and other HTTP-based interactions by allowing users to see the data being sent to a specified endpoint in real time. It is particularly useful for developers who need to test and verify the functionality of their webhooks or outbound messages without setting up a dedicated server.

What Are People Using it For?

  1. Receive Webhooks without needing an internet-facing Web server
  2. Send Webhooks to a server that’s behind a firewall or private subnet
  3. Transforming Webhooks into other formats, and re-sending them to different systems
  4. Connect different APIs that aren’t compatible
  5. Building contact forms that send emails

There are two versions of Webhook.site:

  1. The completely open-source, MIT-licensed version is available on Github, which can be self-hosted using e.g. Docker, is great for testing Webhooks, but doesn’t include features like Custom Actions.
  2. The cloud version at Webhook.site. which has more features, some of them requiring a paid subscription.

Grab Your Unique Webhook.site URL

  1. Open Webhook.site.
  2. Copy your unique URL as shown below.

Automation Champion Approach (I-do):

To solve Warren’s use case, we will use Record-Triggered After-Save Flow and the Outbound Message Action. This approach involves several steps:

  1. Defining an Outbound Message
  2. Salesforce Flow
    1. Define flow properties for record-triggered flow
    2. Add outbound message action 

Step 1: Defining an Outbound Message

  1. Click Setup.
  2. In the Quick Find box, enter Outbound Messages, and then select Outbound Messages.
  3. Click New Outbound Message.
  4. Select the object, Lead that has the information you want included in the outbound message, and click Next.
  5. Configure the outbound message
    1. Enter a Name and Description for this outbound message.
    2. Endpoint URL: https://webhook.site/06eca1dc-cfeb-41f6-9347-2a71a5c7d9cc (Enter the endpoint URL provided by Webhook.site.) 
    3. User to send as: Select the Salesforce user to use when sending the message
    4. Send Session ID: Checked
    5. Lead fields to send: Id, FirstName, LastName, Company, Email, and Phone.
  6. Click Save.

Step 2.1: Define Flow Properties

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Record-Triggered Flow option, and click on Create and configure the flow as follows:
    1. Object: Lead
    2. Trigger the Flow When: A record is created
    3. Set Entry Criteria: None
    4. Optimize the Flow For Action and Related Records
  5. Click the X at the top to save your changes.

Step 2.2: Add Outbound Message Core Action  – to Make SOAP API Call

  1. On Flow Designer, click on the +icon and select the Action element.
  2. Select the Lead Creation Notification outbound message core action.
  3. Enter a name in the Label field- the API Name will auto-populate.
  4. Click Done.

In the end, Warren’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 60
  5. Interview Label: Outbound Message Flow {!$Flow.CurrentDateTime}
  6. Click Save.
  7. Almost there! Once everything looks good, click the Activate button. 

Proof of Concept

From now on, when representatives create a Lead, Salesforce will send an outbound message to Webhook.site. To test this flow, follow the steps below:

  1. Create a Lead in Salesforce.
  2. Check the Webhook.site console to verify that the outbound message was received.

Monitor Outbound Message Delivery Status

To view or track the status of existing outbound messages, navigate to the following path:

  1. Navigate to Setup | Environments | Monitoring | Outbound Messages.
  2. View the status of your outbound messages, including the total number of attempted deliveries.
  3. View the action that triggered the outbound message by clicking any workflow or approval process action ID.

Things to Remember

  1. If the endpoint is unavailable, messages remain in the queue until they are successfully sent or until they are 24 hours old. After 24 hours, messages are removed from the queue.
  2. If a message cannot be delivered, the interval between retries increases exponentially, up to a maximum of two hours between retries.
  3. Messages are retried independently of their order in the queue, which means they can be delivered out of sequence.
  4. You cannot build an audit trail using outbound messaging.
  5. Although each message is typically delivered only once, it can occasionally be delivered multiple times.
  6. If delivery is not successful within 24 hours, the message will not be delivered at all.
  7. If the source object changes after a notification is queued but before it is sent, the endpoint will only receive the latest data, not any intermediate changes.
  8. Due to the possibility of duplicate deliveries, you should check the notification IDs in the notifications delivered to your listener client before processing them.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Go back

Your message has been sent

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

Warning
Warning
Warning
Warning
Preferred Timing(required)
Warning
Warning

Warning.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.