The notions of API and webhook are gradually becoming part of the business jargon, particularly with the democratisation of Nocode.
And yet, they can be complicated to understand. That's what we're going to try and explain in this article. We'll also talk about how to configure a webhook in general time and on Discord. And how to use the webhook in infrastructure development.
Often called "Reverse API" or "HTTP callback", the webhook is a tool that allows to trigger an action when a certain event occurs.
To get into the technical side of things, the webhook is actually an HTTP POST request that will send information (data) via a URL for a specific event.
This data is usually sent in a JSON data structure - which allows the tools to process it.
There are many use cases. Here are some examples:
As you can see, webhooks are an indispensable tool today for automating high value-added tasks based on an event, otherwise known as a "trigger".
Webhooks offer many advantages for developers and users of information systems. Here are five main points:
It is true that one can quickly get lost among these different concepts. The webhook and the API are similar in the sense that they both allow data to be passed between two tools.
The difference is more in the "how". We saw in the previous section that the webhook was event-based. TheAPI isrequest-based. Here, we are going to query a tool to retrieve data - in the form of a GET request. This is called "polling".
Note that there are four types of requests: GET, POST, PUT, DELETE. But this is not so important for the purpose of this article.
APIs are preferred when you have to manage constant changes in data. Indeed, each time you poll the service, new information will be retrieved. One example is data from advertising campaigns such as Facebook Ads or Google Ads.
Using an API would not make sense compared to webhooks for invoice generation. Indeed, the objective here is to trigger an action instantly rather than polling the service at regular intervals to find out whether a customer has purchased a product or not.
Here is an illustration to help you visualise the mechanism and the difference.
The uses are totally different so it is not relevant to compare the two. It all depends on the purpose and the type of data you want to manipulate.
Setting up a webhook depends on the system you're using. However, the general process is similar on most platforms. Here are the general steps for configuring a webhook:
We'll now take a look at how to set up a webhook on discord.
Here are the steps:
Webhooks are generally used to facilitate interactions between two programs or applications, but they can also be used to automate IaC (Infrastructure-as-code) processes and implement GitOps methods.
Infrastructure-as-Code, or IaC, is a method of managing and provisioning IT infrastructures using machine-readable definition files, rather than physical hardware configurations or interactive configuration tools.
In other words, it's all about writing code (which can be verified in a version control system) to define and manage your infrastructure, instead of using graphical user interfaces or manual commands.
Here are a few key points about IaC:
Tools such as Terraform, Ansible, Chef, Puppet and AWS CloudFormation are commonly used to implement IaC.
GitOps is an infrastructure implementation method that uses Git version control systems as a single source of truth for infrastructure and applications. GitOps is often associated with Kubernetes, but the concept can be applied to other systems too.
Here are some key points about GitOps :
All this sounds good, but how does it work in practice?
For years, these tools have been called upon purely and hardly by code. Data has become so important to businesses that Python has now become the most popular language for developers. It is now the language that data engineers use to query and interrogate tools, retrieve data and automate processes.
But fortunately, the Nocode and low-code tools quickly caught up to offer users a much more accessible method of achieving the same results.
We can take the example of Zapier, Make (ex-Integromat) or n8n, the open source automation solution - which offers webhook modules.
A webhook is a tool that triggers an action when a specific event occurs. It is an HTTP POST request that sends information via a URL for a given event. Data is generally sent in a JSON structure.
Webhooks have many use cases. For example, they can be used to create a new contact in a CRM and send a Slack notification to the sales team when a user fills in a form on a site. They can also be used to create an invoice and send an automated e-mail when a user purchases a product on a site, or to send a notification to the Customer Success team when a user's trial period ends.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.
Nocode tools such as Zapier, Make (ex-Integromat) and n8n have made webhooks easier to use for non-technical users. These tools deliver results similar to those obtained with code, but in a more accessible way.