Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "Webhook GET-style" publishing via POST requests (with Jsonpath support) #755

Closed
Fabian-G opened this issue May 29, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Fabian-G
Copy link

💡 Idea
I'm thinking of using webhooks on webex (https://developer.webex.com/docs/api/v1/webhooks/create-a-webhook) to send push messages via ntfy to my phone when there are new messages, which works fine. However, the request send by webex looks something like this (some information stripped):

POST https://ntfy.sh/webex
{
  "id": "<id>",
  "name": "Messages",
  "targetUrl": "ntfy.sh/webex",
  "resource": "messages",
  "event": "created",
  "orgId": "<id>",
  "createdBy": "<id>",
  "appId": "<id>",
  "ownedBy": "creator",
  "status": "active",
  "created": "2023-05-28T19:22:14.720Z",
  "actorId": "<id>",
  "data": {
    "id": "<id>",
    "roomId": "<id>",
    "roomType": "group",
    "personId": "<id>",
    "personEmail": "<email>",
    "created": "2023-05-28T19:22:58.361Z"
  }
}

Therefore (as expected) the notification message is the json body, which doesn't look nice. Since the only real option to modify that request that webex offers is the targetUrl, I thought it would be nice to have the same options mentioned here, but for POST requests and therefore just ignore the body when the ?message="..." parameter is present.

What would be even nicer, is an option to use string interpolation on the parameters, reading values from the body via jsonpath.
For example: If I were to configure the targetUrl in webex as

https://ntfy.sh/webex?message="New message from {{$.data.personEmail}}"

Ntfy would parse the json body and set the message of the notification to "New message from <email>".

💻 Target components

  • ntfy server
@Fabian-G Fabian-G added the enhancement New feature or request label May 29, 2023
@wunter8
Copy link
Contributor

wunter8 commented May 29, 2023

There has been discussion about custom mappings of JSON fields to ntfy's notification fields (e.g., message, title, etc.)

Nothing has been implemented yet, but you can see some of the discussion here: #724

@binwiederhier
Copy link
Owner

This is indeed a dup. I do like this templating approach too. I actually did implement this a year ago I think: #171 + #104

Closing as a dup in favor of #724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants