ProductInsights

Using webhooks in Weavy

May 5, 2023

Weavy was designed by developers to give other developers the building blocks required to quickly and inexpensively extend the functionality of their platforms to remain competitive. While the combination of our APIs, environments, and UI kits give all the core functionality a developer needs, they may not provide all the functionality that they would like. That’s why we recommend that devs who want to unlock the true power of our tools begin experimenting with webhooks.

 

What are webhooks?

A webhook is a software hook that utilizes HTTP functions as its delivery method. This HTTP based callback allows different applications to quickly share information with each other. Typically webhooks act as a form of automation: a signal sent from one app to another that is triggered whenever an event happens, like a new user is created, or a file is uploaded. Though this may sound like an API, it’s important to understand that the two operate in fundamentally different ways. The easiest way to explain the difference is that an API pulls, whereas a webhook pushes. 

 

To illustrate, let’s think of an API and a Webhook as two different delivery services. When you run out of eggs, you ask an API to go to the store and pick up some more for you, if the store has some the API will return with the eggs. A Webhook, on the other hand, would simply deliver you eggs whenever the store restocked. Which of these approaches works best depends on what you need: a home might need eggs on an irregular cadence, whereas a diner needs eggs as often as it can get them.

 

Though APIs allow for incredibly complex integrations between different applications or servers, they aren’t a one size fits all solution. Configuring an API to behave in a way it wasn’t necessarily built to can be as complex as building a whole other application, whereas configuring a webhook to perform a custom function requires much less time or technical knowhow. A webhook can also add a layer of security, as its simple nature precludes a sending app from modifying data within a receiving app.

 

One way I’ve used webhooks in my own life is through home automation. Though my home is filled with smart devices, not all of them are compatible with the same home automation software. But instead of downloading multiple apps to my phone to control every device, I keep a Raspberry Pi connected to my router that acts as a bridge between the different smart home systems. So if I open my garage door, the app that governs the garage uses a webhook to tell my Raspberry Pi, which in turn uses a webhook to tell my thermostat to set the temperature to my “home” preset.

 

How webhooks work in Weavy

Webhooks allow developers to build integrations that subscribe to certain events happening in the Weavy environment. When one of those events is triggered, the environment sends a HTTP POST payload to the webhook's configured URL endpoint, which will then respond to confirm it has received the data.

 

To configure webhooks in Weavy there are three things you need to configure:

 

  1. Payload URL: the URL that the Weavy API will send the webhook data to.
  2. Trigger: the activity in Weavy that will activate the webhook and send the data
  3. Payload: the actual data that will be sent from Weavy

 

One way our team has used webhooks to customize our Weavy Chat experience is through email notifications. The internal app our team utilizes keeps track of unread messages. If a message is left unread for too long, this triggers a webhook in the app. This webhook takes the payload, which is an encrypted packet of all of the messages that are unread, and delivers them to the URL of our email server. Because of how we’ve configured our email server, it knows to decrypt the payload, our unread messages, and send them to the email address associated with the recipient’s account.

 

This of course is an incredibly simple example of how you can use webhooks to customize the Weavy experience. With a little bit of work and experimentation, you can use webhooks to do some very exciting things, which we’re looking forward to sharing with you in forthcoming tutorials.


You can also learn how to set up webhooks by following the instructions on our docs site.

Docs

Weavy

Share this post