mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-11-29 03:40:32 +01:00
add templating for title and message fields
This commit is contained in:
parent
4c0ec3f75b
commit
df7d6baec5
6 changed files with 212 additions and 22 deletions
|
|
@ -3557,6 +3557,29 @@ ntfy server plays the role of the Push Gateway, as well as the Push Provider. Un
|
|||
!!! info
|
||||
This is not a generic Matrix Push Gateway. It only works in combination with UnifiedPush and ntfy.
|
||||
|
||||
### Message and Title Templates
|
||||
Some services let you specify a webhook URL but do not let you modify the webhook body (e.g., Grafana). Instead of using a separate
|
||||
bridge program to parse the webhook body into the format ntfy expects, you can include a message template and/or a title template
|
||||
which will be populated based on the fields of the webhook body (so long as the webhook body is valid JSON).
|
||||
|
||||
Send the message template with the header `X-Template-Message`, `Template-Message`, or `tpl-m`. Send the title template with the
|
||||
header `X-Template-Title`, `Template-Title`, or `tpl-t`. (No other fields can be filled with a template at this time).
|
||||
|
||||
In the template, include paths to the appropriate JSON fields surrounded by `${` and `}`. See an example below.
|
||||
See [GJSON docs](https://github.com/tidwall/gjson/blob/master/SYNTAX.md) for supported JSON path syntax.
|
||||
|
||||
=== "HTTP"
|
||||
``` http
|
||||
POST /mytopic HTTP/1.1
|
||||
Host: ntfy.sh
|
||||
X-Template-Message: Error message: ${error.desc}
|
||||
X-Template-Title: ${hostname}: A ${error.level} error has occurred
|
||||
|
||||
{"hostname": "philipp-pc", "error": {"level": "severe", "desc": "Disk has run out of space"}}
|
||||
```
|
||||
|
||||
The example above would send a notification with a title "philipp-pc: A severe error has occurred" and a message "Error message: Disk has run out of space".
|
||||
|
||||
## Public topics
|
||||
Obviously all topics on ntfy.sh are public, but there are a few designated topics that are used in examples, and topics
|
||||
that you can use to try out what [authentication and access control](#authentication) looks like.
|
||||
|
|
|
|||
|
|
@ -1338,6 +1338,12 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
|
|||
|
||||
## Not released yet
|
||||
|
||||
### ntfy server v2.9.1 (UNRELEASED)
|
||||
|
||||
**Features:**
|
||||
|
||||
* You can now include a message and/or title template that will be filled with values from a JSON body, great for services that let you specify a webhook URL but do not let you change the webhook body (such as Grafana). ([#724](https://github.com/binwiederhier/ntfy/issues/724), thanks to [@wunter8](https://github.com/wunter8) for implementing)
|
||||
|
||||
### ntfy Android app v1.16.1 (UNRELEASED)
|
||||
|
||||
**Features:**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue