DEV Community

Brandin Chiu
Brandin Chiu

Posted on

Extensibilty through Webhooks Part 1: What are webhooks?

At the center of my discussion on Pragmatic Software Design I discussed the four pillars of what I consider to be successful software solutions.

This post revolves around one of those pillars in particular: extensibility, and how we can make our solution as easy to work with as possible for other developers and/or services.

What are webhooks?

A webhook is an automated submission of data over HTTP as a response to some lifecycle event of importance. Users (typically third-party developers) can register to "listen" to these events by providing a URL, which the service will use to submit a request whenever one of those events fires.

Now, why is this useful? Before webhooks, retrieving data out of another system often required some kind of polling. However, polling is inherently inefficient as it generates significantly more network traffic than needed as you constantly ask the service for data.

Webhooks give us the ability to restrict network usage to only the bare minimum needed to obtain the data we're looking for.

As an example, imagine you are looking to integrate with a service that manages users, with another that sends them emails. Service A is responsible for registering and maintaining your primary source of users. Service B maintains a separate list of users that have opted-in to receive marketing, and periodically sends them deals on new products.

If Service A supports webhooks for new user registrations, then it can automatically notify Service B each time a new user registers. Service B can then ingest that data in near real-time, confirm that the user has given permission to receive marketing emails, and then add them to the list of users in Service B.

The true power of webhooks, however, isn't any one specific use-case, but is instead the flexibility for services to integrate with each other in a variety of ways that the initial developers of that service do not expect. It allows for more efficient use of a team's resources by allowing them to focus on their own service, and instead provide a flexible bridge for others to extend the functionality of that service naturally.

Adding Webhooks to your service

Now that we have a handle on what webhooks are and why they might be valuable for us to implement, we're going to discuss a bare-bones and quick way to add webhooks to our own application using Amazon Web Services or Google Cloud.

We want to use a cloud service as the backend for our webhooks because we want to decouple the delivery and execution of our events from our actual application. We want the execution of our webhooks to occur independently from our application -- we're registering endpoint URLs that we do not control and therefore we want any potential errors or issues arising from our webhook requests to be processed externally.

If you're ready, proceed ahead to follow along with the tutorial.

Top comments (0)