Webhooks

What is a Webhook ?

A webhook is a way for an application to provide real-time notifications to other systems when certain events occur. It allows one system to send a message to another system when a specific event happens, rather than the other system constantly polling the first system for updates. This can be more efficient and less resource-intensive than using APIs for frequent updates.

Why Use Webhooks ?

Webhooks are commonly used in scenarios where a system needs to be notified of events in real-time, such as when a new damage is added to the database or when a new vehicle is inspected.

In the case of vehicle inspections using ALTO AI, it is important to note that the damage detection process may take from 20 seconds up to 90 seconds. To avoid having to poll the API repeatedly and potentially causing unnecessary load on the system, it is required to set up a webhook to receive a notification when the inspection is complete. If a webhook is not set up, the inspection results will still be available on our HUB after the damage detection is done.

Using the Webhook Feature

To use the webhooks feature, the developer needs to subscribe to the relevant events and provide a callback URL to which the notifications will be sent. When the specified event occurs, the API will send a notification to the callback URL with the relevant data, such as the following:

{
  "tchekId": "oPm2A5et6m",
  "message": "Tchek created successfully ! After the damage detection is finished, you will find the result in our Hub https://webapp.tchek.fr/en/dashboard/scans/detail/oPm2A5et6m. You can download the JSON by using the Actions button on the top-right corner and choosing Download inspection JSON. To automatically receive the JSON, we also suggest setting up a webhook. Check our documentation at https://tchek.gitbook.io/documentation/api-endpoints/webhook/configuration"
}

The TchekId is a unique identifier that allows you to correlate the results of the webhook with your API calls.

The webhooks feature can be used in conjunction with the mobile application to receive notifications when an inspection is complete and access the results. This can be especially useful for developers who are creating custom products or services that rely on the inspection data provided by ALTO AI.

It is important to note that webhooks are not activated by default and you will need to configure them, and also to subscribe to the events you want to be notified about.

Webhooks Resources

If you are new to webhooks and would like to learn more about how they work and how to use them in your projects, here are some resources that may be helpful:

To get started with creating your own webhook server, you can use a framework or library like Express in Node.js, Slim in PHP, or Gin in Go. Here is a simple example using Node.js and the Express framework:

const express = require('express')
const app = express()

app.post('/webhook', (req, res) => {
  // Handle the webhook request
})

app.listen(3000, () => {
  console.log('Webhook server listening on port 3000')
})

You can also find more detailed examples and tutorials on using webhooks with various backend technologies by searching online or checking out repositories on GitHub. For example, this GitHub repository contains a simple Node.js server that listens for webhook requests and logs the data to the console. You can use this as a starting point for your own webhook server or customize it to fit your specific needs.

Last updated

Was this helpful?