Flying by Webhooks!

Abdulmohsen Alenazi
4 min readJan 30, 2021

Webhooks are a way for apps to communicate between them automatically.

What does meaning Callback Service?

A callback service that will notify your system when you create, change or delete an event. This is useful e.g. when you want to mark an order as paid, update your shop’s inventory, and so on.

The callback service is asynchronous and as such will not interfere with or prolong the processing time of the API request generating a callback. eg. the time your customer will have to wait for payment confirmation.

A “callback” is a function that is called when something happens.

How it works!

When you create, change, or delete a resource an HTTP POST request is sent to the callback URL.So, here we have endpoint I’ll consume it when the event should be reflected the new changes.

What does meaning WebHook?

A webhook is an API concept that’s growing in popularity!. Call webhooks reverse APIs, With most APIs, there’s a request followed by a response. No request is required for a webhook, it just sends the data when it’s available.

A Webhook mechanism that uses a publish-subscribe pattern, which means the consumer will update subscribers when it’s happened action subscriber waiting for it. for example when I paid for something and waiting for shipping. the process work when your payment has successful. and the (system) subscriber gets new status from webhook.

Instead of the user polling a server asking if the state has changed, the user can only say: “Hey, you know what? YOU tell me when the state changes”.

The observer pattern could be implemented in any event-driven systems, but webhooks are restricted to, you guessed it, the web. This implies that they must communicate over a web protocol — HTTP in almost every cases.

An event-driven architecture is software promoting the production, detection, consumption of, and reaction to events. An event can be defined as “a significant change in state.”

How does a webhook operate?

You can register a webhook by registering the URL to notify once given events occur. This first step is usually done via either a UI or by API.

The route created holds the logic to be executed once the event occurs.

This way, a system doesn’t have to know the nature of what needs to be executed, it only needs to keep track of the routes to notify.

It’s really powerful since everything remains decoupled. System B, receiving the notification through the chosen URL, not only knows an event occurred on another system, but it can also react to it.

The route holding the logic has to be accessible through an HTTP POST request.

A POST request being the method that allows the transfer of information in the body of the request through HTTP.

why user webhook?

Every time a customer pays you through a payment provider ou have to manually input their details into your membership management application. This is just so the user can log in.

For a better user experience, this of course, quickly becomes tedious as the rate of new members increases. If only the payment gateway provider and your membership software could communicate with one another. That way anyone that pays through the payment provider is automatically added as a member.

Using a webhook is one way to make this happen.

Let’s assume that both payment provider’s and the membership management software have webhook integrations. You’d then be able to set up the payment provider integration to automatically transfer a user’s information over, each time payment is made.

Connecting your mobile number marketing software with other applications through a webhook can open up a lot of possibilities:

  • You can use a webhook to connect a payment gateway with your mobile number marketing software so that a user gets an SMS whenever a payment bounces.
  • You can use webhooks to sync customer data in other applications. For example, if a user changes their Claim information address you can ensure that the change is reflected in your CRM as well.
  • You can also use webhooks to send information about events to isolated databases or data warehouses for further analysis.

Webhooks vs APIs (Pulling vs Pushing)

With an API, you get data through a process known as “polling.” This is when your application periodically makes a request to an API server to check for new data.

A webhook, on the other hand, allows the provider to send (i.e “push”) data to your application as soon as an event occurs. This is why webhooks are sometimes referred to as “reverse APIs.”

Hope I explained it well by @MohsenEnazi

--

--