How to Use Webhooks in Salesforce

You can utilize webhooks in one of two ways in Salesforce: through custom development work or by downloading an app in the AppExchange.

In our last blog post we explained how you could use webhooks for creating powerful connections between Salesforce and third-party platforms. However, because there are no webhooks organically in Salesforce – just outbound messages – savvy users (like yourself) have to figure out how to use webhooks in Salesforce from scratch (or pay a developer to do this). Don’t worry, that’s why we wrote this post! Find out how you can harness the power of webhooks for your business below.

But first.. We should explain some basics about what Salesforce does offer – outbound messages.

What are outbound messages and what the heck is SOAP/XML?

Outbound messages are one of the ways to send information to an endpoint and they are sent in XML (a kind of markup language for organizing data). You can use them to send an object’s field data to an external application based on specific requirements and triggering events.

Outbound messages can be helpful when creating an integration, but they have limitations. A few notable drawbacks are listed below:

  • No response logging – you can’t see if a callout failed or when to retry a callout.
  • Message order isn’t guaranteed. If you have a record being synced multiple times over a day, you can’t guarantee the latest update is reflected in the final record. Simply put, the order an Outbound message arrives cannot be guaranteed.
  • No response processing – this results in a “fire and forget” process.
  • Not user friendly or modern – SOAP/XML is harder to work with than JSON. Modern APIs are now mostly all JSON-based and do not support SOAP/XML.

So outbound messages and SOAP/XML are outdated and chunky options to connect two systems. What else can you use?

As you probably know, there’s always the option to create and use custom APEX code, but anyone who’s gone that route before knows that can be difficult, complicated, and expensive. Businesses need something scalable, easy to learn, and robust – and none of the options we’ve discussed are that.

Don’t give up hope just yet!

Webhooks are an effective and efficient way to connect your Salesforce org to a third-party platform. Since Salesforce doesn’t provide this capability out of the box, you’ll either hire a developer to implement them or find an app on the Salesforce AppExchange to support your integration powered by webhooks.

Custom Development

To implement an integration with an external system using REST API, you need to build a few classes in APEX:

  • First, you need to have a class that can handle the actual API: authenticating, making calls using HTTP classes (details here), logging calls, converting JSON to be sent or received as response. You can even use inner classes that will map to the JSON request and response, for easy access later on. It’s best practice to store all the integration details used by this class (URL, credentials, settings) as a record in custom metadata or other configurable settings like custom labels. Let’s call this class MyIntegrationAPI.
  • The other class is a helper class, where you can write the logic part of the integration. In this class you can have methods that can map the data from Salesforce into a request and then use data from the response to take different actions in Salesforce. Let’s call this class MyIntegrationHelper. This class acts as a middleman: it’s called from other places in Salesforce (triggers, custom buttons, lightning component, scheduled jobs) and it calls methods from MyIntegrationAPI.
  • If you need inbound integration as well, you need to create a Webhook class, let’s call it MyIntegrationWebhooks. This class has a @RestResource annotation and can also call methods from MyIntegrationHelper to take action based on an incoming call.

Nevertheless, if you’d like to learn more on how to custom-develop your own REST integrations, you can check out the following links:

Confused? Don’t worry! We receive integration requests a lot. To bypass the lengthy steps above, we created a Salesforce AppExchange App so you can create integrations easily – no developers needed! You’ll learn more about this below.

Salesforce AppExchange App

The team at Omnitoria loves Salesforce, but we love the Salesforce AppExchange even more. The ecosystem has over 9,000 apps you can choose from – most offering free downloads. There’s an app for pretty much anything you can think of, including webhooks! Take your time browsing the “Integration” category or simply type “Webhooks” in the search bar.

If you’re interested in a robust and low-cost way to implement webhooks, don’t forget to click the Declarative Webhooks app listing. Declarative Webhooks is a no-code, scalable and flexible app that supports complex business processes with third-party platforms!

Even though Salesforce doesn’t offer the ability to utilize webhooks out-of-the-box, with an app like Declarative Webhooks, your options to create powerful and strategic integrations is essentially limitless.