mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-05-09 08:26:00 +02:00
[GH-ISSUE #1076] Triggering Webhook upon Receiving Notifications #756
Labels
No labels
ai-generated
android-app
android-app
android-app
🪲 bug
build
build
dependencies
docs
enhancement
enhancement
🔥 HOT
in-progress 🏃
ios
prio:low
prio:low
pull-request
question
🔒 security
server
server
unified-push
web-app
website
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ntfy#756
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @afunworm on GitHub (Mar 29, 2024).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1076
💡 Idea
💻 Target components
I understand that NTFY is intended to be a simple notification server. However, given that it has email forwarding feature, it would be extremely useful to implement webhook action upon receiving notifications.
It's as simple as this: When a notification is received, perform an outgoing Webhook.
This would greatly expand the capability of NTFY. For example, I can use NTFY as a central location to take in all notifications, then probably distribute the notifications somewhere else, like a Discord/Slack channel, or send them off to other applications to collect data, performing searches, etc. The possibility is endless.
If this sounds like it will deter NTFY from what it is doing, I'd love to learn to contribute to make this happen.
Thank you.
@binwiederhier commented on GitHub (Mar 29, 2024):
Performing outgoing HTTP requests to untrusted servers is a security issue. Here are just a few dangerous things, but I'm sure there are more:
As a result of this, ntfy will never support calling outgoing HTTP requests for untrusted URLs.
I hope you understand
@afunworm commented on GitHub (Mar 29, 2024):
Hello.
Thank you so much for the explanation. I overlooked the fact that I was using the self hosted version, which was also the publicly available versions hosted by ntfy and other contributors. This would, in fact, raise a lot of security concerns, to perform unwanted outgoing webhooks, since there are public users that can access the platform.
Is it possible for you to let me know where in the script you started to send out the notifications to the client? I am thinking of digging deeper and maybe forking it just for my own use. I understand it shouldn't be done publicly, but the possibilities of NTFY being able to do these things are so appealing to me.
I apologize in advance for asking this, but are you available for hire if I'd like to make this work just for me? I only need a simple script to be activated every time a notification is received.
Either way, this is an extremely great project and I can't think of a single day I didn't use it since I discovered it.
Thank you so much.
@wunter8 commented on GitHub (Mar 29, 2024):
You can use this to activate a script every time a notification is received on a specific topic: https://docs.ntfy.sh/subscribe/cli/#subscribe-to-multiple-topics
@afunworm commented on GitHub (Mar 30, 2024):
This looks very promising! One last question, how do I pass the data to the script though? NTFY will have the body and the title, and optionally the tags, priority, etc. Is it possible to access these variables within the script?
EDIT: Never mind, there's a section for the variables. I'll play with it.
Thank you again, so, so much!
@afunworm commented on GitHub (Mar 30, 2024):
Hello.
I played with it for a bit and realized the 'run a command for every notification only' works when you subscribe to a topic using CLI, then publish a message via CLI. In other words, a topic
testin CLI is different than a topictestsubscribed via other methods, such as web UI or mobile apps. When a message is published through methods such as HTTP, email, etc., to the topictestthat was subscribed to from the Web UI, for example, it won't trigger the command set for thetesttopic from the CLI.Is there any way to use the 'run a command for every notification' function from the CLI while still utilizing the ease of publishing a message from the other method, such as HTTP, email, etc.?
Thank you.
@wunter8 commented on GitHub (Mar 30, 2024):
The
ntfy subcommand can react to messages sent from any client (Android, web, CLI, curl, etc.).I'm guessing you sent messages to your self hosted server and that the
ntfy subcommand was misconfigured and was subscribing to thetesttopic on ntfy.sh instead of thetesttopic on your server@afunworm commented on GitHub (Mar 30, 2024):
Hello.
I am using the Docker self hosted version. The command should be written inside the docker container at
/root/.config/ntfy/client.yml, am I correct?@wunter8 commented on GitHub (Mar 30, 2024):
No, for the root user, it should be at
/etc/ntfy/client.yml@afunworm commented on GitHub (Mar 30, 2024):
Hello.
Is there a way to check if the server and the client are using the same host? I've made sure that inside the Docker Container,
/etc/ntfy/client.ymlhas thedefault-host: https://myserver.comand/etc/ntfy/server.ymlhasbase-url: https://myserver.com.I am able to receive the notifications coming to the topic

test(on PWA app) when I dontfy pub test Hello!:And it shows up everywhere:

But the nothing happens in the CLI subscription:

The
/etc/ntfy/client.ymlis pretty straight forward too:It feels like I'm getting really close as soon as I can figure this out somehow.
EDIT: I removed the
default-hostfrom/etc/ntfy/client.ymlto use ntfy.sh to test, it worked. I subscribe to the topic fromntfy.sh/randomTopicNameand the notification will go through the ntfy CLI. It's just when I switched it back tohttps://myserver.com, the CLI stopped receiving notifications.Thank you for all your help so far. I truly appreciate it.
@wunter8 commented on GitHub (Mar 31, 2024):
You need to do
ntfy subscribe --from-configwithout including any topics in the command (since they are already listed in the config file)And since
ntfy pub testsends to your self-hosted server butntfy sub testdoes not subscribe to your self-hosted server, that might be a bug in the code. I'd have to test something's myself.@afunworm commented on GitHub (Mar 31, 2024):
I've spun up a new VPS and kept all the files
docker-compose.yml&/etc/ntfy/server.ymlthe same, and the server works. I can subscribe to from another computer using NTFYntfy suband everything worked fine. As soon as I switched back to the other VPS, it stopped working.Is there any particular port (besides the one ntfy server is on, in this case, 80) that needs to be opened for the polling? Besides the
cache.db,user.db,webpush.db,/etc/ntfy/server.yml,/etc/ntfy/client.ymlanddocker-compose.yml, is there any other files that need to be preserved to replicate an instance at its 100%?I tried using
ntfy serverwith debug and there was no error shown up when subscribing or publishing at all. I'm not sure what the next step might be. If there is a hidden bug somewhere, how would you propose I diagnose it?Thank you.