GitHub - tomasz2001/motoko_webhook

https://github.com/tomasz2001/motoko_webhook/

Dear friends, I have prepared a library that adds webhook functionality to your canister backend. Imagine your AI agent reading data from your canister—without you having to struggle to make it happen. If defining massive types in `main.mo` isn’t your favorite task, and dealing with HTTP functionality feels like a nightmare, then this library is exactly what you need. It works right out of the box. The `main.mo` file is kept minimalist; it serves to test the library before you deploy it to production, while also demonstrating how to import it.

Bob Marley " Don’t worry about a thing
'Cause every little thing gonna be alright
Singing, "Don’t worry about a thing
'Cause every little thing gonna be alright "

Cat Hug Love: Hug Coming Your Way

You may want to check out https://mops.one/liminal. It may cover some of the same areas.

Impressive how you managed to slip in a gif in this god forsaken forum. Kudos, please don’t share. Thank you :wink:

While looking at the code of this library, I came to the conclusion that even though there are libraries providing what looks like very similar functionality at first glance, they are not the same thing.

In this post, I would like to clear up any misconceptions.

I would also like to apologize in advance for any lack of information regarding the webhook_hotplug.mo file and its role in the library.

Philosophy: Unix Principle vs. All-in-One

Let’s start with the liminal library, which is a technological “combine harvester” combining many functionalities. I won’t go into detail explaining it because the repository’s README has already done that.

My project, on the other hand, is based more on the Unix philosophy: “Do one thing and do it well.”

My goal was to create a solution for a 2-canister application (frontend + backend) that allows them to expose an API gateway via the backend canister — for example, for devices from the ESP32 family and others where libraries like ic-py cannot be implemented.

Simplicity of Implementation

The entire library was designed to be simple and not require writing huge amounts of additional code for implementation.

The main.mo example from the project demonstrates how simple the implementation is:

Motoko

public func greet(name : Text, value : [Webhook.Webhook]) : async Text {
   set_webhook(value, name);
   return "drop";
};

The Role of webhook_hotplug.mo

Looking at webhook_hotplug.mo, the library also takes care of generating ready-to-use functions and an array for the webhook.

Unfortunately, this may imply individual implications in specific cases due to compiling the same functions twice. Because of this, webhook_hotplug.mo is used as an optional component of the library, intended to be applied only when there are no contraindications to do so.

this is interesting.