Demystifying Webhook for Marketers (a beginner’s guide)

The dummy guide to webhook

A quick analogy

Let’s just imagine that someone pressed the time machine and the clock is turned 25 years back where internet is still not a thing and attention span of humans is larger than a dolphin.

I have a bank account running, and I like to get updates whenever there is an activity in my account, like credit or debit.

Now, to get an update from the bank I have to call them and ask for it. A bank staff, on the other hand, would review my account and inform me accordingly. This process would be repeated each time I need an update.

Seeing their employees going through the same pattern every time a customer calls, the bank comes up with an idea.

They decide to launch a callback plan wherein they would themselves call the customer whenever there is an activity in their account. Customers needn’t call now.

What is a Webhook?

Simply put, those callbacks of yesteryear, which updated customers, are the webhooks of today.

Webhook is a programming mechanism to receive data, that originates in some external system, in real time. In this case, that system is the bank account.

For instance, say, you are using WebEngage to create onsite lead generation survey. Now suppose, as soon a user submits the survey, you want the data to be passed on to an external destination like your warehouse or CRM such as Salesforce.

There are two ways to accomplish that,

  • manually download the list periodically, in absence of an automated data pipeline, and upload it to your external system. Not really efficient, is it?
  • Or, set up an API that would constantly poll WebEngage for data at a certain interval. But even that is inefficient because a) it is not real time b) it is highly probable that there has been no submission since the last polling.

Difference between webhook and API

Then, there is a third way- Webhook. With Webhook you would be able to pass data as soon as it happens. Like, notifying the customer as soon as the transaction happens.

How exactly Webhook works?

A webhook is nothing but an HTTP callback. A webhook provider makes an HTTP callback to a URL that has to be configured by the system which receives the data. That URL is called Webhook endpoint, it should be public and like I said it belongs the to the receiving system.

The callback is triggered whenever there is an event in the webhook provider about which it wants to notify the other system. The data that is passed during the callback, is mostly in the form of JSON or XML format. Depending on the webhook provider there could be more options like the kind of events you want to be notified about, format of data etc.

Need some headspace to chew this over? You would be able to connect the dots by going through the following example

A simple example

Take an example from WebEngage product itself which provides Webhook.

So, whenever there is a survey submit event, WebEngage would make an HTTP POST request to the URL fed above. Below is the example of a simple payload that is generated when someone submits the survey.

{
    'qualified_lead': {
        'contact': {
            'email': 'jon@snow.inc',
            'tel': '+01-2222-333'
        },
        'industry': 'ECommerce',
        'purpose': 'Growth hacking'
    }
}

There is not a universally common format to send the data. There are certain providers which provide options around the data format you want the data in. But in its absence, you would have to write an intermediate program to transform that data into the format that you could pump into your system.

That’s Webhook, guys.

So, if we sum everything up we get the final definition of Webhook as, “Webhook are HTTP callbacks to feed data, usually in JSON and XML, to the system of your choosing in real time.”

Simple, right?

To understand how Webhook fits in the entire bank analogy, let’s recall it again.

  • In the bank’s case, application is the bank account,
  • URL is the customer,
  • Webhook is the call made by the bank staff to the customer and
  • JSON/XML is the information or data passed.

Some more real-life examples

Foursquare – Foursquare notifies applications using their webhook when users checks in.
Stripe – Delivers various payment-related events like payment completed, payment failed, recurring payment disabled, etc
Papertrail – Provides real-time alerting for server health monitoring.

Hope that this was helpful.

The best of marketing automation tips, straight to your inbox.

Join 40000+ businesses who trust WebEngage for their marketing.