Skip Navigation

Lemmy Webhook - add webhook support to your Lemmy instance

github.com

GitHub - RikudouSage/LemmyWebhook: Add webhook support to your Lemmy instance

Note that unless you're a Lemmy instance admin, this doesn't have much use to you.

Until this package came along, if you wanted a bot that responds to events, you had to manually traverse all comments/posts/whatever at a fixed interval. With this package you can actually react to events directly from the database. It's implemented in a very efficient way by connecting the package directly to the Lemmy database and using native Postgres features to get the events (LISTEN/NOTIFY if you want to get technical).

The webhooks themselves are inserted into a separate SQLite database (API is coming) and allow for both simple and complex filtering of the incoming data. The system is already in use by two of my bots, @ChatGPT@lemmings.world and @DallE@lemmings.world who now both receive the information about being tagged in a comment in seconds (the actual reply takes a little longer, but that's because of the nature of the bot).

Currently you can be notified about a post or a comment, other types are trivial to include as well.

Let me know what you think!

21 comments
  • This is awesome. I really like that. Hope it becomes an official optional setting you can turn on or off in the instance config.

  • what are the resource use implications of something like this? will it scale well with a large instance?

    • Yep, it uses pushing from the postgres to the webhook processor instead of polling for data periodically by an app. So after every insert, an event is pushed using the native postgres listen/notify mechanism and then the webhook processor doesn't interact with the database at all.

      • yeah, but im seeing a reference to the doubling of my standing-processing as now i have an insert-after-event that didnt exist before... is that right?

        i mean i get that youre pushing the processing to a different, functional mechanism, but its still additive processing on the server that needs accounting... and seems expanded.

  • Hey this is pretty cool! I wanted something similar for my instance, with a webhook notifying me of any application request, so I can get a notification and react as soon as possible. Well, I ended up having to implement that from scratch within my @AutoMod@lemmy.basedcount.com bot. A solution like this would probably be WAY more efficient than my current setup (with a client continuously polling for new applications). Good stuff!

    • Should be simple to rewrite the bot to accept input from this! If you plan on doing so, let me know, I'll add support for the applications table.

      • I have a bit too much stuff going on in my life right now to focus on changing my Lemmy stack, I'll have to stick to my current setup for the time being.

        But I am very much interested in the package. Gonna leave a star on its repo and hopefully I'll remember to come back to this once my hands are a bit less full than they are now.

21 comments