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

receiving outside web hook messages #161

Open
Smiley-k opened this issue Nov 16, 2023 · 19 comments
Open

receiving outside web hook messages #161

Smiley-k opened this issue Nov 16, 2023 · 19 comments
Labels
question Further information is requested

Comments

@Smiley-k
Copy link

Hi, I am using glpi (https://glpi-project.org/) solution to handle user requests, the standard sending method is email, but also glpi can send notifications via web hook, (at the moment I have done sending to Rocket Chat directly), but I also found your solution and it is very interesting. Did the setup it works, but I can't understand apprise can receive the push (web hook) from GLPI ?! could you please guide me, thank you very much.

The web hook system itself

https://github.com/ericferon/glpi-webhook

And for this to work all the time apprise should run as a service? Or some element of it? - I can't figure that out either...

Thank you very much.

@Smiley-k Smiley-k added the question Further information is requested label Nov 16, 2023
@caronc
Copy link
Owner

caronc commented Nov 16, 2023

Apprise by itself just triggers notifications for you in a common/universal method.

If you want to be able to receive a webhook and then in turn relay it along, you can do 2 things:

  • upgrade your application to use Apprise instead of qlpi-webhook 😉
  • keep using qlpi-webhook and additionally set up a web hosted version of Apprise (see here or see the docker hub version).

Let me know if i miss-interpreted your question

@Smiley-k
Copy link
Author

Thank you, yes you understood me correctly, I was looking at this solution by adding API - but it seemed redundant to me so I came with a question maybe there is some other way.... but apparently this is the only way... I will try it...

@caronc caronc transferred this issue from caronc/apprise Dec 29, 2023
@Smiley-k
Copy link
Author

@caronc My attempts have failed miserably..... I have never been able to get GLPI webhook to send messages to the apprise and apprise-api =(

@ovizii
Copy link

ovizii commented Mar 7, 2024

It looks like webhooks were added last year in November: #97

But I can't find any documentation about how we can use it. I would also like to have an app send a notification via a webhook interpreted by apprise-api which then sends it out. I know how to do this with curl triggering apprise-api but not who it works with a webhook.

@caronc
Copy link
Owner

caronc commented Mar 8, 2024

See here for how it works. It's a hook added to Apprise-API to issue a webhook call after instructed to perform an notification.

I agree with you that the documentation is very poor.

@ovizii
Copy link

ovizii commented Mar 8, 2024

Thanks for the quick reply. I did search extensively before posting, and I had found that link you shared. When I found that I already realized there might have been a misunderstanding somewhere down the line. :-(

I'll share some of the links I found here in the issues and explain where the misunderstanding lies. Of course, I might be wrong, please do not hesitate to correct me if I am misreading something.

#97
Is asking for:

it would be great if apprise-api has an endpoint for receiving messages in json-webhook format.

I have the same use case: support an application that has a fixed json payload. In my case it is Grafana.

Then there are two links to tools which seem to complement apprise-api to do just that:
https://github.com/camalot/apprise-webhook “Webhook receiver for apprise”
https://github.com/mrtwnklr/apprise-it-for-me “About
A gateway that accepts HTTP POST data, transforms it into an apprise notification payload”

To which you replied:

Closing this ticket off as the requested webhook support has been added.

So I went searching everywhere and only found this webhook which apprise can use to reach out, the exact opposite way of what was asked :-) hence I thought I had missed something and posted here.

@caronc
Copy link
Owner

caronc commented Mar 9, 2024

I think this just comes down to my lack of knowledge of what is being asked; it's definitely not you. I can be a bit slow sometimes 😉

My confusion:
Apprise-API is already listening as a Web API end point for webhook calls (and sending notifications from them). If I understand your request correctly: you need it to support a different set of webhooks outside of what it already does?

The links you shared identify another application that enables incredible amounts of flexibility of tailoring how a POST can be received (different then what Apprise-API accepts). Then in turn, the application just makes the POST to Apprise that it wants in the format that is already documented here. Is that correct?

Are you asking for some kind of heavy built in flexibility to the URL being posted to Apprise-API? Or maybe just a single new endpoint format that aligns with a particular piece of software that only posts in 1 way (so adapt Apprise-API to support this too)?

I'm just trying to gather more information for what is being asked (sorry if i'm misunderstanding anything here).

@ovizii
Copy link

ovizii commented Mar 9, 2024

Thanks for your understanding and your interest in my request. I just want you to know, I'm just an end-user, I might have got a few things wrong too. Let's see if I can properly explain my (and possibly the other posters) “requests”.

I'm running apprise-api locally on my little server and I figured out how to configure a few notification services. In my case email, pushbullet, home assistant and recently ntfy which is supposed to replace pushbullet.

So far I mainly use apprise with some cron and bash scripts to trigger notifications. I use the curl method. In the apprise-api dashboard I also see examples for python and PHP.

Now I started using a few tools which can send out their notification via webhook.

An example of one which can easily be adapted to apprise-api is tautulli. See images:

image

image

Then there are others with absolutely no way to configure the webhooks like outline wiki:

image

So I naively just asked if there is a way to get this working but now that I have read up more about this subject, I think apprise-api is already offering the maximum flexibility.
My current workaround is to notify a local instance of n8n which in turn “translates” and pushed the notification to apprise-api.

The links you shared identify another application that enables incredible amounts of flexibility of tailoring how a POST can be received (different then what Apprise-API accepts). Then in turn, the application just makes the POST to Apprise that it wants in the format that is already documented here. Is that correct?

I never used any of those links, they were from other people in these issue threads. I went with n8n, it's way more flexible, can connect any service to any other service.

@caronc
Copy link
Owner

caronc commented Mar 12, 2024

Interesting, but what if there is a quote in say the {title}, won't that break the JSON payload that gets pushed?

Based on what you shared, you can just post your (Apprise-API) request to:
URL: https://your.apprise.server/notify/your-key/?tag=optional-tag
JSON Data:

{
   "title": "{title}",
   "body": "{title} {other-fields}"
}

Or no?

@ovizii
Copy link

ovizii commented Mar 13, 2024

:-) I guess so. I was a bit naive and new to all of this when I first looked into this and when I saw other people requesting the same thing, I didn't think it through further.

Now that I set up n8n as webhook and read their manuals on how to transform any of the received data into other fields I would like to pass onto apprise, I feel like I have a deeper understanding of the matter.

Nothing further needed from apprise's side and at least we clarified that me and the other people in the issues were looking for something else than you added (a webhook apprise triggers).

I'm happy using n8n as a “middleman” as it also allows me to link many more integrations into this workflow besides triggering a notification via apprise.

@caronc
Copy link
Owner

caronc commented Mar 13, 2024

Your request is still valid. What i suggested may or may not work.

Leave the ticket open and give some things a try. A fully customizable POST endpoint with tailored payload entries seems like a lot of overkill (especially if the sending side is already providing this). But a few alternative posting methods that i can adapt the Apprise API to isn't unreasonable. 🙂

I'll await your feedback

@caronc
Copy link
Owner

caronc commented May 13, 2024

Does this help you: #189 ?

@ovizii
Copy link

ovizii commented May 13, 2024

That is a perfect workaround for me as I can insert the mappings straight into the receiving URL which means even the most inflexible senders can make use of this!

@caronc
Copy link
Owner

caronc commented May 13, 2024

Great, well let me know how it goes, it's been pushed into the latest release already. If it suffices, we can close this ticket. Alternatively let me know what you would like to see changed! 👍🙂

@ovizii
Copy link

ovizii commented May 22, 2024

Hm, let me follow up with another question. Your example:

curl -X POST   \
   -F "body=Test Message" \
   -F "tags=all"  \
   "http://localhost:8000/notify/apprise-api-key?:content=body&:subject=title"

Assumes a proper curl command. If you look at my above example, sometimes we don't have that luxury available.

image

In this case I have no way of specifying any tags. Would it be possible to also add those to the URL, i.e.
http://localhost:8000/notify/apprise-api-key?:content=body&:subject=title&:tags=tag1,tag2

@caronc
Copy link
Owner

caronc commented May 22, 2024

That should work with the current design, if not, try:

  • http://localhost:8000/notify/apprise-api-key?:content=body&:subject=title&tags=tag1,tag2

Basically, drop the : infront of tags and see if that helps?

@ovizii
Copy link

ovizii commented May 22, 2024

Hm, I tried manually with curl and the tags does work as you explained. Still not able to use the webhook from outline as shown in the screenshot above.

I used this URL (yes, I used "apprise" as my config ID as I didn't know better when I first started using it)
https://apprise.int.domain.tld/notify/apprise?:content=body&:subject=title&tags=mytag

apprise shows these errors:

   2024-05-22 06:49:06,075 [WARNING] django: NOTIFY - 172.16.2.2 - Payload lacks minimum requirements using KEY: apprise                                   │
│   2024-05-22 06:49:06,075 [WARNING] django.request: Bad Request: /notify/apprise                                                                          │
│   [pid: 145|app: 0|req: 3415/3529] 172.16.2.2 () {46 vars in 832 bytes} [Wed May 22 06:49:06 2024] POST /notify/apprise?:content=body&:subject=title&ta   │
│   gs=ntfyk20 => generated 47 bytes in 1 msecs (HTTP/1.1 400) 6 headers in 374 bytes (1 switches on core 0)                                                │

Any ideas or tips on what I am doign wrong?

@caronc
Copy link
Owner

caronc commented May 22, 2024

It almost seems that you're using an older version of the Apprise API that isn't handling the mapping for you; please double check.

In the meantime, I'll investigate on my end this weekend if i can

@ovizii
Copy link

ovizii commented May 22, 2024

Oh, btw. I found the docs for outline's webhooks:

image

Can I map any of that json payload like in your curl example with say ?:content=event ?

I saw your latest comment, not sure about my version. I use this linuxserver image: image: lscr.io/linuxserver/apprise-api:latest and my apprise GUI shows 1.8.0
image

Anyway, I appreciate all your help, I will check if I can figure this out on my own and update this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants