[GH-ISSUE #134] Add action buttons to notifications to allow for user response to ntfy message #109

Closed
opened 2026-05-07 00:20:06 +02:00 by BreizhHardware · 7 comments

Originally created by @mrherman on GitHub (Feb 8, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/134

Add the ability to add clickable responses to a ntfy message. This is allowed in android notifications (called notification actions: https://developer.android.com/training/notify-user/build-notification.html#Actions). To make it consistent across all the ways to view a message I think it would also need to be added to the ntfy app's list of messages (adding clickable buttons under the message) and to web push notifications.

The action taken when a button is pushed could be a message published on a topic determined by a header set in the original notification and text indication which button. In this way the server that sent the actionable notification can just listen on a determined topic for a reply and to take action. The number of buttons and their text could be set in the same way.

Action buttons in a android notification (concept):
image

Originally created by @mrherman on GitHub (Feb 8, 2022). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/134 Add the ability to add clickable responses to a ntfy message. This is allowed in android notifications (called notification actions: https://developer.android.com/training/notify-user/build-notification.html#Actions). To make it consistent across all the ways to view a message I think it would also need to be added to the ntfy app's list of messages (adding clickable buttons under the message) and to web push notifications. The action taken when a button is pushed could be a message published on a topic determined by a header set in the original notification and text indication which button. In this way the server that sent the actionable notification can just listen on a determined topic for a reply and to take action. The number of buttons and their text could be set in the same way. Action buttons in a android notification (concept): ![image](https://user-images.githubusercontent.com/1773927/152996787-6aefd65c-0c3f-4271-b1e0-cc8f30b08335.png)
Author
Owner

@s-h-a-r-d commented on GitHub (Apr 8, 2022):

Would love to have this feature.

Not sure how it is implemented but HomeAssistant has a feature like that: https://companion.home-assistant.io/docs/notifications/actionable-notifications/

Maybe the client does a POST to the server?

<!-- gh-comment-id:1093083199 --> @s-h-a-r-d commented on GitHub (Apr 8, 2022): Would love to have this feature. Not sure how it is implemented but HomeAssistant has a feature like that: https://companion.home-assistant.io/docs/notifications/actionable-notifications/ Maybe the client does a POST to the server?
Author
Owner

@binwiederhier commented on GitHub (Apr 15, 2022):

I'm going to work on this next. I am still brainstorming, but this is the idea so far:

curl \
  -H "Action: Show Tweet; view; https://twitter.com/binwiederhier/status/1467633927951163392" \
  -d "Somebody tweeted about ntfy" \
  ntfy.sh/tweet-alerts
  
curl \
  -H "Action: Open HomecamApp; open; org.homecamapp" \
  -H "Action2: Call police; http-post; https://police.com/..." \
  -d "Garage door sensor motion alert" \
  ntfy.sh/garage-door-alert

My thoughts are that I can provide a limited syntax via HTTP headers, and then if you really want to pass more details, you can pass the message as JSON (https://ntfy.sh/docs/publish/#publish-as-json), something like

curl -d '{
  "message": "garage door alert",
  "actions": [
    { 
      "action": "open",
      ...
<!-- gh-comment-id:1100468862 --> @binwiederhier commented on GitHub (Apr 15, 2022): I'm going to work on this next. I am still brainstorming, but this is the idea so far: ``` curl \ -H "Action: Show Tweet; view; https://twitter.com/binwiederhier/status/1467633927951163392" \ -d "Somebody tweeted about ntfy" \ ntfy.sh/tweet-alerts curl \ -H "Action: Open HomecamApp; open; org.homecamapp" \ -H "Action2: Call police; http-post; https://police.com/..." \ -d "Garage door sensor motion alert" \ ntfy.sh/garage-door-alert ``` My thoughts are that I can provide a limited syntax via HTTP headers, and then if you really want to pass more details, you can pass the message as JSON (https://ntfy.sh/docs/publish/#publish-as-json), something like ``` curl -d '{ "message": "garage door alert", "actions": [ { "action": "open", ... ```
Author
Owner

@s-h-a-r-d commented on GitHub (Apr 16, 2022):

Let us know if you need any help testing

<!-- gh-comment-id:1100723435 --> @s-h-a-r-d commented on GitHub (Apr 16, 2022): Let us know if you need any help testing
Author
Owner

@binwiederhier commented on GitHub (Apr 22, 2022):

📢 User actions: Request for testing

How to test

Server:

  • Run server binary with ntfy serve --cache-file cache.db (a db upgrade is required, so you may want to not use your prod db)
    Android:
  • Back up current settings via Settings -> Back up to file
  • Uninstall ntfy from phone
  • Download .apk to phone and install it
  • Subscribe to local ntfy test server

Then navigate to https://<testserver>/docs/publish/#action-buttons and play with it.

<!-- gh-comment-id:1106676280 --> @binwiederhier commented on GitHub (Apr 22, 2022): 📢 **User actions: Request for testing** - Server binary (amd64): https://phil.nopaste.net/ntfy-am64-actions?d=1&f=ntfy&a=vcbWyfDPkw - Android apk: https://phil.nopaste.net/ntfy-actions-android.apk?d=1&f=app-play-debug.apk&a=IkjnamhB0I **How to test** Server: - Run server binary with `ntfy serve --cache-file cache.db` (a db upgrade is required, so you may want to not use your prod db) Android: - Back up current settings via Settings -> Back up to file - Uninstall ntfy from phone - Download .apk to phone and install it - Subscribe to local ntfy test server Then navigate to `https://<testserver>/docs/publish/#action-buttons` and play with it.
Author
Owner

@binwiederhier commented on GitHub (Apr 22, 2022):

@s-h-a-r-d @mrherman This is ready for testing :-D

<!-- gh-comment-id:1106678006 --> @binwiederhier commented on GitHub (Apr 22, 2022): @s-h-a-r-d @mrherman This is ready for testing :-D
Author
Owner

@binwiederhier commented on GitHub (Apr 23, 2022):

📢 Updated test binaries:

Server:

APK:

<!-- gh-comment-id:1107343912 --> @binwiederhier commented on GitHub (Apr 23, 2022): :loudspeaker: **Updated test binaries:** Server: - https://phil.nopaste.net/t7XjlVBntr?d=1&f=ntfy&a=qsyn9vej8g - `wget -O ntfy-actions-amd64 "https://phil.nopaste.net/t7XjlVBntr?d=1&f=ntfy&a=qsyn9vej8g"` APK: - https://phil.nopaste.net/T7d7JOvNRH?d=1&f=app-play-debug.apk&a=uVxXKVl4wn
Author
Owner

@binwiederhier commented on GitHub (Apr 23, 2022):

Will be in the next release

<!-- gh-comment-id:1107345411 --> @binwiederhier commented on GitHub (Apr 23, 2022): Will be in the next release
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#109
No description provided.