Webhooks Basics

This article will review the basic concepts of webhooks and how to use them to get data our of Hatch.

This reference article covers the basics of webhooks to give you the building blocks you need to create your own. Looking for steps on how to create a webhook in Hatch? Refer to Creating a webhook.

What are Webhooks?

Webhooks are a way for one application to send real-time information to another whenever a certain event happens. Imagine it as a phone call: when something specific occurs, like a new message on a chat app, the app can "call" another app to let it know about the new message. This happens instantly and without you having to check manually.

Webhooks are powerful tools that enable real-time communication between applications, enhancing automation and reducing manual effort. By understanding how they work and their benefits, businesses and developers can leverage webhooks to create more integrated and responsive systems.

How do Webhooks Work?

  • Event Triggering: A webhook starts with an event in an application, like a new order placed in an online store or a new comment on a blog.

  • HTTP Request: Once the event occurs, the application makes a special kind of request (HTTP POST request) to a unique URL provided by another application or service.

  • Receiving and Processing: The receiving application gets this request and processes the data sent with it. For example, if it's a new order, the receiving application might update inventory or send a confirmation email.

Key Concepts to Understand

  • URL Endpoint: This is like a specific phone number that the sending app knows to call when an event happens. It's where the data will be sent.

  • Payload: This is the data that gets sent with the request. It could be information about the event itself, like details of a new order or the content of a new comment.

  • HTTP Request Methods: Webhooks typically use HTTP POST requests to send data. This means they send data securely and efficiently over the internet.

Why Use Webhooks?

  • Real-Time Updates: Instead of checking for updates manually, webhooks allow applications to receive updates instantly as they happen.

  • Automation: They automate processes between different applications, reducing manual work and improving efficiency.

  • Integration: Webhooks help different applications work together seamlessly, like notifying a messaging app of new data in a project management tool.

Use Cases in Hatch

  • Opt-Out: Triggered when a contact opts out of texts by replying STOP or END, or
    when a Hatch user manually opts the contact out of communications in the UI
  • Opt-In: Triggered when a contact opts back into texts by replying START
  • Contact Created: Triggered when a new contact is created in Hatch
  • Contact Edited: Triggered when contact information is edited in Hatch
  • Contact in Campaign: Triggered when a contact receives the first message in a messaging campaign
  • Bot Conversation Completed: Triggered when a bot bails out, discards, or completes a successful conversation. Can also share answers to interactions for any of those outcomes.
  • Contact (Email or Phone) Expired: Triggered when the email or phone of a contact with temporary information expires