Hey folks, I've been working on this for a couple of months. It's a tool and service that lets you send push notifications to your (Android) phone via simple PUT/POST requests, like so:
curl -d "hi there" ntfy.sh/mytopic
It's open source and easily self-hostable. It has tons of features (though I'm still working on many), and there's also an Android app.
I'd love some feedback, and I'd love it even more if you started using it. I'm doing this for funsies, but I'm also running it as a real service/project, with uptime monitoring and all that.
Back then, i want to receive a notification directly to my phone whenever "an event" happened on my server. So, i did this :
1. Create a Telegram bot by using BotFather (/newbot), get its HTTP API access token.
2. Invite that bot to a group, make it as a administrator.
3. Invite @RawDataBot to that group. It will tell the group's chat_id.
4. Done. If we want to trigger the notification, just send HTTP GET to https :// api.telegram.org/botBOTTOKEN/sendMessage?chat_id=CHATID&text=URLENCODEDTEXT . Replace BOTTOKEN with your bot's HTTP API access token , CHATID with the group's chat_id, and URLENCODEDTEXT with the notification text body (url encoded).
Thank you for making this open source. At least, by using this, now i can self-host everything without having to rely to Telegram anymore.
If you're on android you can also use MQTT Client[1] and Tasker[2] to receive MQTT messages and further process it the way you like. You need a MQTT broker, Any RPi could serve as one.
P.S. Congratulations on the launch OP, I've been looking at gotify for a while and would try to use yours when the need arises.
First of all, I love your username. Are you affiliated with the rsync tool or just an rsync lover like me? If you are, I bow my head to you and thank you. :-D
If you are happy with SMS and twilio, then use it. Having many options is generally always awesome.
The main reason I made ntfy was because I mumbo jumbo (that's a technically term) on all sorts of servers for work and for fun, and I often do things in a tmux or screen that take forever, like rsync something (ha!) or reseed a MySQL replica. On many of those servers, I cannot or should not install anything, and I certainly don't want to leave an auth token in the bash history.
For those use cases, having a short command to ping me when something is done is FREAKING AWESOME. This has become muscle memory to me by now:
rsync -av bla root@myserver:/bla; curl -d "rsync done" ntfy.sh/philalerts
No auth token. No looong string of things. Just a simple curl.
But again. If you're happy with SMS+twilio, then there's no reason to switch. Though I would love it if you could give it a shot.
"First of all, I love your username. Are you affiliated with the rsync tool or just an rsync lover like me?"
I am merely an rsync lover like you.
In 2005 I named my company rsync.net because I thought it was descriptive of the service.
Prior to naming it that, I explicitly asked permission from both the original author of 'rsync' and the maintainers at the time. They said they had no problem with it.
Just yesterday was checkout out rsync.net
Anyways, notifications means no cost. I can run this server along with my existing vps. Twilio is quickly pricy in some countries. Also unencrypted if you want to keep your alerts private. Top of my head these are things I can think of.
Will you be flooded with spam messages now that you have published the magic URL?
Some twisted soul could even put sending a message to you via cronrab every minute, and you don't seem to have any way to block it, or filter it from the rest.
I'd say that it's infinitely better to have an opaque an otherwise useless API token in your bash history than to have a URL of a bare and uncontrolled web service in the same bash history, and now on the open internet.
If I were to design a service like that, I'd have an URL like domain.api/username/${token}, where the token can be changed and / or retited, should it become a target of a spam attack. Exporting this token once in the beginning of a shell session should not be hard; SSH even allows you do it with SendEnv.
As for the retirable token, you are right. In the current approach this cannot be done. I have an open ticket for auth (optional) that I'll soon implement. I want to get it right, so if you have thoughts, I'd love input on it: https://github.com/binwiederhier/ntfy/issues/19
Yes that's correct. You control your own destiny. If you choose any of the demo topic names, you may be getting spam. If you choose your username, likely not. If you choose "phil-likes-dogs" then there's almost no chance someone will guess that.
If (you're into microoptimizing things and) all you care about is whether they're mobile, you can leave out `Type=caller-name` to save a whole one cent per lookup :)
And if you're doing this before you try to SMS them, you can skip the lookup entirely, if it's a landline you'll just get an error back.
(I work at a company that uses Twilio heavily and it's full of this sort of microoptimization)
I think SMS is an American thing at this point? Your approach definitely would work fine but I’d not have thought about SMS if you gave me a year on this issue. It is an obsolete, half forgotten thing here.
I confirm this. It's also true that they seem to be the only users of SMSes now. People are using WhatsApp or Telegram or Messenger, roughly 90-9-1 in my experience (Italy.) Cost is not the issue because plans include at least hundreds of SMS if they are not unlimited. It's functionality: pictures, vocals, videos, multi user chats, etc.
I was never a huge SMS user, but as far as I can tell, it seems pretty on par with chat services these days. I guess technically it's MMS, but who cares (or knows)?
I have a group SMS with family where people are constantly sharing pictures etc and it is working fine.
I wish Apple itself had a service like this. Make it part of iCloud. Give me a URL and a token so I can just send a push notification to my phone without an app. Make it part of the OS.
Without an application what is the difference between a notification and a text message/iMessage?
I can see spammers creating schemes to obtain peoples notification URL/address and bombarding them with multimedia popup ads with no ability for the user to block them.
Tying notifications to apps at least means that there is some audit trail and ability for users to stop receiving notifications and ultimately for the developer/sender to be removed entirely.
> Without an application what is the difference between a notification and a text message/iMessage?
SMS isn't secure and I can't send an iMessage from the command line. Push notification is the only way to get a message securely to my phone.
> I can see spammers creating schemes to obtain peoples notification URL/address and bombarding them with multimedia popup ads with no ability for the user to block them.
I addressed this in a sibling comment -- it would still go through Apple's servers and there is a lot they can do to mitigate that.
> Tying notifications to apps at least means that there is some audit trail and ability for users to stop receiving notifications and ultimately for the developer/sender to be removed entirely.
If apple ran the service, they would have all the same paper trails and mitigations.
If they did that then scammers would coax people into giving them access to the push token and the victims would be receiving spam notifications that would be very hard for them to get rid of. We already see that kind of stuff with spam calendars. I don’t see Apple enabling such kind of push notifications.
> If they did that then scammers would coax people into giving them access to the push token
Since it would still go through apple servers, they could put mitigations in place, such as checking for repeated messages to multiple accounts, one IP pushing to multiple accounts, the actual content of the message, etc. They could also put an interface right on the phone that lets you mark it as spam. They could also give you an easy way to rotate the key.
> What kind of use cases do you have in mind?
- Set up a cron to trigger an push when I know we need to leave the house.
- Set up a cron to trigger a push at 7pm to all the phones in the house to remind the kids to come to dinner (and remind me it is dinner time).
- Use a weather API and the Nest API to determine when it is time to open or close the window and push that.
- Use my cameras to determine when the postman has arrived and then push that the mail has arrived.
- Basically any useful household information that can be gathered via API and pushed without anyone having to ask for it.
Sure, there are plenty of services that I can sign up for where I can install their custom app and then send my private messages in the clear to their servers.
But the point is I want Apple to do it so I don't have to rely on a 3rd party. I already have to trust Apple with my private data and for the most part rely on their servers to be up.
Wonder if there's a way to use shortcuts to do a kind of pubsub that can produce notifications. A little googling resulted in this, which looks.. perhaps similar..? to what you're looking for, but 3rd party: https://www.pushcut.io
As far as I can tell that API goes the other way -- it makes it so home assistant can query custom entities. But I think you'd still have to make a request for the information, it can't be automatic?
Hello Philipp, what benefits do you think make the app shine against something like Gotify? It looks like you have integrated with firebase. What else should I be looking for? The firebase path looks interesting for my 'toy' messages so save some battery life.
Howdy, I didn't know Gotify existed when I started writing ntfy, so it's in a sense very similar because it makes sense this way.
ntfy is open by default, meaning no need to create accounts or set up anything. You can use it without having to remember a token or anything. That means you can use it easily on servers where you cannot install anything, e.g. at work.
It's also a pub-sub system and not just a notification system, so you can do stuff like collect data from multiple machines super easily with multiple publishers and one subscriber [1], and whatever else you can think of.
In terms of features, I'm lagging behind a little on some things (images, nice web UI) but I'm ahead on others (scheduled messages, tags/emojis, webhooks support, email notifications, publish via email, see more [2]). I've also got a CLI that can run commands on incoming messages which is pretty neat (see [3]). Plus, i think the docs are pretty neat too.
I suggest you give it a go and tell me what you think. It's pretty easy to install the app and uninstall if you don't like it.
Yeah I just saw your rsync example above and it's indeed a very nice feature, to not have authentication, because at those times that I would need this I would certainly not feel up to hassling with installing/setting up Gotify (I do have a Gotify server running though).
I shall setup and play with this, thanks!
Edit: It was exactly for things like `bash long-running-script.sh ; notify "done"` that I installed Gotify in the first place, but I've never actually used it like that. This I surely will!
Hurray. I acquired a user. :-) Let me know if you have any questions or problems. I am usually pretty quick to react. You can leave questions in GitHub issues [1] or in Discord [2].
1. The F-Droid flavor of the app [1] does not require or use Firebase. And: If you self-host the server and use the Google Play flavor [2] of the app, it won't use Firebase either.
2. I've just started work [3] on making ntfy a UnifiedPush (https://unifiedpush.org) distributor, meaning that other apps/services will be able to use ntfy.sh (or a self-hosted server) as a means to deliver notifications or messages. I'm super excited about this, and I don't think it'll take very long.
I look forward to that. I wouldn't try it without unified push but if you add that, it could be easily be better than gotify which really only provides the bare minimum.
Hmm, I'm not very well versed in Android push messaging, but how does your self-hosted binary send notifications? Don't you need to include GCM keys somewhere?
A "foreground service" means 2 things: an unremovable notification is shown to the user in their notification tray AND specifically for ntfy, an additional connection open (additional battery usage) on top of the one engineered by Google.
Although I like seeing things attempt to compete with Google, this can't come close because of the restrictions of Android enacted by Google.
Yes, sadly Google/Android makes it impossible to do it in a battery efficient manner. UnifiedPush [1] is attempting to create a competitive mechanism that apps can use and share for notifications and server-to-device messages. There is still one open connection, but it can be shared by all apps on the phone.
I have recently started work to make ntfy a UnifiedPush distributor [2].
Side note:
- you _can_ actually dismiss the foreground service notification, see [3] for a screenshot
- the battery impact is not as severe as I had thought initially. On my phone, it's about 4% battery over 17h "use" [4]. I'm planning on making "slow delivery" possible to counter this bahavior, see this ticket [5]
I noticed UnifiedPush and your efforts there and I am curious. My summary after a brief glance is UnifiedPush will not achieve anything useful, for the same reasons: iOS and Android push notifications are locked down. For example, sure, Android is OSS, but most of the functionality is provided by proprietary apps or Google Play Services. This results is challenges today, but further challenges down the road (App Store rules/policies change, stronger enforcement).
About the battery usage, this is always a hard question to answer. 4% is very low, which seems good. But how could you measure that effectively? Perhaps if the connection is good, it might take 4% battery over 17h of "use". But could this be worse if network is intermittent (i.e. realistic conditions)? Or lots of data being used (or *abused*).
As binwiederhier said 'it is what it is' with proprietary platforms. However, you can still avoid going through Google now for the apps that do already support UnifiedPush
Additionally, supporting UnifiedPush (code and adoption by app devs) is supporting:
1. Non-google app stores (e.g. F-Droid with it's great selection of FOSS apps)
2. Google-free distributions of Android
3. Linux phones
The above amount to a small but non-trivial community, but imho supporting (or participating in) them ethically is something I like.
Yeah I mean it is what it is. We can all only work on the space that exists. The big boys control the market and the eco system.
One battery saving idea: there is a ticket to let the user control the interval at which the topic is polled. Right now it's obviously a persistent connection. But likely polling every 5min may consume less battery.
Ahh, thanks, that clarifies things! One feature request I had was to use encryption so FCM can't read your notifications, but that might not be what your service is for.
I'm very curious if anyone knows of any software that does the opposite, i.e. running an arbitrary command on my computer when I tap a button on my phone.
You can do this with a combination of ntfy and MacroDroid [1] or Tasker. With those apps, you can do things like "if I shake my phone, publish this message to this HTTP endpoint". And then you can subscribe to a ntfy topic via the ntfy CLI and execute a command.
Here's how you do it:
1. Install MacroDroid [1] on your phone
2. Set up an action in MacroDroid to publish a message to a ntfy topic via a HTTP GET (see [2])
3. On your computer, install the ntfy CLI and set up the ntfy-client systemd service (or use `ntfy subscribe mytopic 'echo $m'` or something similar); see instructions here: [3]
Here are some screenshots/videos of how to integrate MacroDroid and Tasker with ntfy [4]. Please note that the MacroDroid notes are a little out of date, since you can now use HTTP GET to publish messages, so you don't need to use the "Send intent" thing anymore, which means you don't need the ntfy app on your phone.
If you need more help, you can find me on Discord [4] and I'll help out.
I needed something similar, a reverse 'wake-on-lan' command that shuts down or reboots systems (but could be any kind of action), so I created a telegram bot that presents the list of commands over telegram chat app. I liked that I did not have to open any ports or serve http pages, the bot is really just a script that's long polling the telegram servers via https/json.
It's not an out of the box solution, and only if you don't mind third party solutions, but firebase has really solid bindings on both android and in python. In less than a day I had an android app that would trigger routines via a python app listening to firebase on my workstation, and send push notifications in response when it was done.
Termux with a shortcut or widget to run a script that runs SSH will do that easily if you can ssh from your phone to computer (so, same LAN or VPNed or such).
I have pretty rigorous rate limiting based on IP address [1]. If you have lots of IP addresses at your disposal, I may have a problem. So far it's been fine.
Thank you for the feedback. Always makes my day. ;-)
If you think this is a good setup and many people will run it like that, we could add it to the docs as an example on the install page: https://ntfy.sh/docs/install/
I didn't write an app, however. I rely on the browser notification API which doesn't have the best support on mobile unfortunately. It works great on desktop.
My inspiration was the same though. I do most of my work over ssh, and wanted a local desktop notification when a slow command was finished running.
Oh wow ! is quite powerful. Some of these bang commands are quite questionable, but hey... Like !12 runs the 12th command from the bash history. That's seems super dangerous to me.
Just a few days ago I wanted to set up a service that would allow me to receive notifications on my mobile phone that would alert me when the very long processes that I neeed to leave running at work unexpectedly crash, saving me from the burden of having to monitor them continuously.
I was reading some guides to understand how to configure Firebase and deploy all the the necessary parts on an Azure server. But now, thanks to this, I can get everything up and running in a matter of a few minutes. You have saved me a lot of time. Not to mention the ability to easily integrate it with the other command line tools I often use. This is huge. Thank you so much for this, I'm going to get a lot out of it.
I would probably just use Slack and Slack-bots for a low-code approach to this. Are there major downsides? I don't believe you would need to pay for Slack to use primarily for up to a few dozen Slackbot messages per day.
As I've said in another comment [1], if you're happy with what you have then by all means stick to it. I think the major upside of ntfy (aside from the bagillion features of course) is that it's so FREAKING EASY, and that it doesn't have auth. You probably don't remember your Slack auth token by heart. With ntfy, you can do:
The major downside I see is you have to use Slack for that. If you're already in that ecosystem it's fine, though their notifications preferences could use a bit more configurability.
I surely will! I also saw there's an RPM for it, so that makes adoption that much easier. I really, really, really dislike having to re-compile to update things. It just never happens lol.
Sadly no. I picked the name and bought the domain before I found out about it. When I found out I created a PR [1] to integrate the two. It's not been merged though.
Given that I bought the domain and all that I'm kinda sticking with the name though.
If you choose "mytopic" as a topic, yes. If you choose "eximius-1", probably not. If you are paranoid, you can choose "ZfxdjfdkAFHFJKL" and then you have an "auth token".
That said, auth is on the list of things to add. It'll be optional and I will try to make it simple. There's a ticket for it here [1]
I was wanting something like this recently, but specifically to send notifications and notifications-with-images to my watch. Bonus points if i can choose the icon the latest iOS has next to it.
Anyone familiar with something to achieve this? Preferably self hosted
The best thing I found was a Telegram bot, but that's not secure. Unfortunately, nothing I've seen is, because Google will see your notification text for GCM anyway.
In the Google Play flavor [1] and with ntfy.sh, yes. If you use a selfhosted server or use the F-Droid flavor [2], then no. In those cases a foreground service with a persistent connection is used.
You can find more info on the configuration page for a self hosted server [3].
You may want to check out this question in the FAQ too [4]
You can also turn off publishing to FCM for ntfy.sh on a per-message by message basis [5].
I felt bad about that one ;-) It's on purpose to grab the attention of Mac folks to solicit help. But you're right it's not very kind. I'll change the wording.
I'd love some feedback, and I'd love it even more if you started using it. I'm doing this for funsies, but I'm also running it as a real service/project, with uptime monitoring and all that.