Webhooks: An Introduction

Sean Ryan
Sean Ryan
Nov 20, 2018 · 3 min read

What’s a Webhook? Or… When Life Give You Lemons

First things first, you might be asking: ‘What the hell is a webhook?’

Simply put, a webhook is a method of initiating or changing a behavior of a web application utilizing custom HTTP POST requests also known as callbacks. “Hooked” yet? No? Ok, let’s expand on that. Picture that you’re in the business of lemonade in 2018. You run a lemonade e-comm business called “Pucker Up,” and you want to provide the highest possible value to your new and returning customers. Picture a user story as follows involving webhooks:

  1. A user comes to your page and is greeted by your sites built in chatbot who asks what they might be looking for today.
  2. Your user has interest in the Sour Cherry Lemonade product that you carry, and they ask your chatbot if that product is currently available.
  3. The chatbot provides the pricing and all relevant product information to the user for the Sour Cherry Lemonade
  4. The user decides he/she wants that product and asks the chatbot to add it to their cart, which the chatbot does
  5. The user requests information from the chatbot on a few more items, asks to add all the items to their cart, and asks the chatbot to bring him/her to check out, which the chatbot all does.

How did this all happen? As you can probably guess, with webhooks. Webhooks specialize in setting up specific workflows which are triggered by specific user actions. In this example, our user makes multiple requests to our chatbot, including viewing product information and adding items to their cart. These requests trigger their respective workflows for the chatbot to initiate, and the user receives the proper data or behavior on the client side.

This is merely one example, and webhooks can be utilized in a variety of other ways such as through Stripe who has a variety of webhooks, including one that will automatically send a notification email to a customer who’s subscription payment fails.

Setting Up A Webhook

Setting up a webhook is surprisingly simple, and all that it requires is registering a callback URL with whichever company or service you are requesting data from or initializing a workflow. Facebook Messenger has a surprisingly easy set up to create your own chatbot through their webhook, and their service even allows you to set up or integrate your own custom workflows that can live on your company’s Facebook Page for greater user support or care.

Webhooks vs. API’s

You may have been asking “Why should I use a Webhook? Can’t I simply use an API?”, and the answer is yes, you can! However, there are a few key differences between Webhooks and API’s:

  1. API’s place calls even when there is potentially not data, while Webhooks sit and wait to be triggered through specific user actions, preventing wasteful API calls.
  2. Webhooks provide your applications with nearly perfect real-time information. While this is possible through API’s, they involve additional configuration and utilize more resources then webhooks.
  3. Webhooks can be utilized when the API being called is very poor, or there is no API at all. Workaround solutions to deliver data that your application needs to function can be sent through a webhook!

Get “Hooked In”

Webhooks are being utilized more and more around web development, and are being offered through a variety of services. Stripe and Facebook Messenger were mentioned above, and additional services such as Zapier allow you to link certain apps together that can trigger actions within each other through webhooks. Github utilizes webhooks to update third-party applications about repository updates, and companies like SendGrid use webhooks to automate specific emails through user actions (such as shipping confirmations or password resets).

If you’re beginning to develop a new service or revisiting how your current services are running, you may find that webhooks can make your services smoother than a fresh glass of lemonade.


Sean Ryan

Written by

Sean Ryan

I’m a Fullstack Javascript Developer. Before developing, I worked for a few places digital shops including Vaynermedia and Laundry Service.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade