caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
11.93k stars 416 forks source link

Slack Block Kit support #641

Open joarobles opened 2 years ago

joarobles commented 2 years ago

:question: Slack Block Kit support?

Is it possible to add Block Kit support for Slack notifications? I think that the notification body might be a JSON attribute instead of markdown text.

caronc commented 2 years ago

Interesting... i wonder if it could be more designed similar to how the MS Teams Templating section was done.

joarobles commented 2 years ago

I think so, but that would require to have the template located elsewhere and couldn't be easily integrated with the stateless API.

Maybe the body attribute could receive markdown or json based on a URL parameter (like bodyFormat in this example)?

{
    "urls": "slack://xoxb-asd123/%23general?bodyFormat=json",
    "body": [
        {
            "type": "section",
            "text": {
                "type": "plain_text",
                "text": "This is a plain text section block.",
                "emoji": true
            }
        }
        ]
}

So the body content would be directly set in: https://github.com/caronc/apprise/blob/1816c448aca348425b46d5ac76db90505f5b6bf8/apprise/plugins/NotifySlack.py#L384.

joarobles commented 1 year ago

Hi @caronc! Did you have the chance to take a look at this? It would be very nice to have this feature to enrich Slack messages

caronc commented 1 year ago

Hi, i didn't forget, it's jsut so hard to prioritize all of the tickets open. I tend to do bugs first and super quick and easy enhancements first. :slightly_smiling_face:

This request I think i'm still scratching my head on. Apprise is really meant to just be a quick and dirty message system. Not a fully featured (all bells and whistles for all end points). This is a grey area as blocks sure are feature rich. You definitely need to provide it a full JSON object. It steps away from the title body, and message type (warning, info, etc) style.

MS Teams kind of has a feature like this as well which crosses this line, but it's able to do it as a template. At the end of the day, the MS Teams object still only takes a body and title. But the template is as big as you want it to be with {{body}} references you can pass in the data to. The template to use is identified on the Apprise URL. So like:

the :target=Chris and :whence=value become additional variables you can pass into the template...:whence populates any {{whence}} entries you identified in your template. So that gives you more dynamic entries.

I don't quite agree with the idea of passing in a full JSON object because how would other services receive it; they'd just end up passing the JSON along. You end up defining a feature that ONLY works with one service (exclusively) and would look awful through all others.

Do you see where I'm coming from?