[SOLVED] Ntfy attached txt

4kn30x

New Member
Nov 18, 2024
7
15
3
Following the recent implementation of Webhook notifications I discovered that instead of sending the entire message as it used yo do with SMTP notification, it sends a attachment.txt file containing that text.

Is there any way to send directly the text instead of having to download and open that file every time?
 
  • Like
Reactions: Johannes S and RN1
Just to clarify, you mean that you've configured a webhook target that sends notifications to ntfy.sh and there the notification text is displayed as an attachment? Or are you talking about emails sent by an SMTP target?
 
  • Like
Reactions: Johannes S
Hi,
Yes, the first one.
Actually I have both SMTP and Webhook at the moment, that's how I have realized the difference.
As an example, let's say I would backup a VM, the content of the email send with the SMTP target would be the entire log of the backup job.
The same action, notified using Webhook target to ntfy, with "{{ message }}" as body, results:
"Title"
You received a file: [U]attachment.txt[/U]
With the entire log of the job inside the attachment.txt file.
 
Last edited:
  • Like
Reactions: Johannes S and RN1
  • Like
Reactions: Johannes S
Well, yes. I've set up a webhook target for ntfy.sh using the proxmox documentation you have linked above.
My setting are, in order:
Method: POST
url: myntfy.instance
Header: Authorization : {{ secrets.mykey }}
Markdown : yes
X-Title : {{ title }}
Body : {{ message }}

It would appear that {{ message }} handlebars doesn't link to the text raw data but instead generate a .txt file containing the text.

Would there be another handlebars expression linking to the raw text data? Or maybe there isn't any way to have the full text in webhook target for ntfy as we have for SMTP?
 
  • Like
Reactions: Johannes S
It would appear that {{ message }} handlebars doesn't link to the text raw data but instead generate a .txt file containing the text.

Would there be another handlebars expression linking to the raw text data? Or maybe there isn't any way to have the full text in webhook target for ntfy as we have for SMTP?

The full notification text will be sent if you use {{ message }}. After some experimentation, using the same configuration as you provided, it looks like ntfy will display the notification text as an attachment if it exceeds a certain size. This is not really a thing we have control over from our side. Maybe consult ntfy's documentation to see if there is a way to influence this behavior.

Maybe we could add a handlebars helper to limit the text lenght to a certain number of characters or lines. This might help, but then of course potentially interesting information could be cut off ;)

How many VMs are you backing up in your backup job?
 
Last edited:
I cannot believed I've missed that...
Ntfy server.yml sample:
"# - message-size-limit defines the max size of a message body. Please note message sizes >4K are NOT RECOMMENDED,
# and largely untested. If FCM and/or APNS is used, the limit should stay 4K, because their limits are around that size.
# If you increase this size limit regardless, FCM and APNS will NOT work for large messages."

Thank you for steering me into the right direction.
 
Last edited: