Slack Notifications


Recommended Posts

It would be great to have Slack support for notifications.

Either using the tokenized App Web API or the Incoming Webhooks feature of Slack would be great!

I'm already using plexPy, couchpotato, and sonarr Slack Notification integration, but it would great to have unRAID join the party.

Link to comment
  • 1 month later...
  • 1 month later...

And a bump... anyone have any word on this request?  This is the one notifying thing I use that hasn't added Slack Notifications yet.

 

If not an official method, what's the best way to hack the existing notifications system to feed to Slack via one of the other notification agent options?

Link to comment

If you want to be adventurous and support your own notification agent, look at the file /usr/local/emhttp/webGui/include/NotificationAgents.xml

 

This file is used as an API between unRAID and agents. Any new entries can be simply added here and agents become instantly available to unRAID.

 

Challenge Accepted:

 

<Agent>
    <Name>Slack</Name>
    <Variables>
      <Variable Help="Get your WebHook as explained [a href='https://api.slack.com/incoming-webhooks' target='_blank'][u]here[/u].[/a]" Desc="WebHook URL" Default="FILL WITH YOUR OWN">WEBH_URL</Variable>
      <Variable Help="Application name, e.g., unRAID Server." Desc="Application Name" Default="unRAID Server">APP_NAME</Variable>
      <Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable>
      <Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable>
    </Variables>
    <Script>
      <![CDATA[
      #!/bin/bash
      ############
      {0}
      ############
      TITLE=$(echo -e "$TITLE")
      MESSAGE=$(echo -e "$MESSAGE")

      curl -X POST -d "payload={\"username\": \"$APP_NAME\", \"text\": \"*$TITLE* \n $MESSAGE\"}" $WEBH_URL 2>&1

      ]]>
    </Script>
  </Agent>

 

This seems to work for Test, but has two issues:

[*]No Icon and I don't see where to specify in the XML.

[*]Won't save the variables for the WebHook URL and channel

 

My assumption is that some handling code that ingests/transforms this XML defines the available variables and the icon. 

For the variables, next step is to reuse some of the unused ones like maybe APP_TOKEN and USER_KEY, but I'd rather use something that makes sense.  But at least the Proof of Concept works.

 

Ideal of course would be if LimeTech took this and ran with it.

 

ADDENDUM:

Nope, changing the new variables to reuse older unused variable names from other notifications doesn't let it save the settings.  All works fine in test.  I guess for now I'll have to either hardcode it or set the default values to my values (setting default to personal settings works).

Link to comment

1. The icon image needs to be stored in folder /usr/local/emhttp/webGui/icons. The name of the icon is the name of the agent in lowercase and spaces removed. In your case "slack.png". The icon size is preferably 48x48.

 

2. It is not possible to store or reuse your own variables.

 

1. Thanks that worked nicely:

TWFNDPD.png

 

2. Some variables work if you hardcode in your values as "default".  Just can't save different values.

 

Also I took out the channel field since you can set that up on the Slack WebHook Custom Integration side.

 

 

With default hardcoded values for the webhook URL, it's working nicely:

 

iJTcMdo.png

Link to comment
  • 2 months later...

1. The icon image needs to be stored in folder /usr/local/emhttp/webGui/icons. The name of the icon is the name of the agent in lowercase and spaces removed. In your case "slack.png". The icon size is preferably 48x48.

 

2. It is not possible to store or reuse your own variables.

 

1. Thanks that worked nicely:

TWFNDPD.png

 

2. Some variables work if you hardcode in your values as "default".  Just can't save different values.

 

Also I took out the channel field since you can set that up on the Slack WebHook Custom Integration side.

 

 

With default hardcoded values for the webhook URL, it's working nicely:

 

iJTcMdo.png

 

1.) I wonder where unraid keeps info that notification agent was enabled.

2.) Where do i have to copy unraid logo to see it in my slack, similar you have on your pic

Link to comment
  • 2 weeks later...
  • 1 month later...
  • 5 weeks later...
1 hour ago, jrdnlc said:

Is it normal for the Slack agent to disappear after a reboot on the server? It's not longer under my notifications settings tab

If you're modifying the file according to this:

Then yes, as unRaid is unpacked fresh from every reboot, and any changes to system files are lost.  You need to set up a script or something to inject those changes you're making at every boot (probably via the user scripts plugin)

Link to comment
3 minutes ago, Squid said:

If you're modifying the file according to this:

Then yes, as unRaid is unpacked fresh from every reboot, and any changes to system files are lost.  You need to set up a script or something to inject those changes you're making at every boot (probably via the user scripts plugin)

 

dammit. I'll wait and see if someone can help with a user script plugin then lol

Link to comment
13 minutes ago, jrdnlc said:

 

dammit. I'll wait and see if someone can help with a user script plugin then lol

Make the changes again.

 

Then from the command prompt:

cp /usr/local/emhttp/webGui/include/NotificationAgents.xml /boot/NotificationAgents.xml

Then add a user script (set to run at array start) composed of

cp /boot/NotificationAgents.xml /usr/local/emhttp/webGui/include/NotificationAgents.xml

But, bear in mind that should LT incorporate Slack notifications in a future release of unRaid, then you're effectively overwriting their changes with yours.  (Generally, its not recommended to overwrite system files unless you are aware of the consequences)

Edited by Squid
  • Upvote 1
Link to comment
16 minutes ago, Squid said:

Make the changes again.

 

Then from the command prompt:


cp /usr/local/emhttp/webGui/include/NotificationAgents.xml /boot/NotificationAgents.xml

Then add a user script (set to run at array start) composed of


cp /boot/NotificationAgents.xml /usr/local/emhttp/webGui/include/NotificationAgents.xml

But, bear in mind that should LT incorporate Slack notifications in a future release of unRaid, then you're effectively overwriting their changes with yours.  (Generally, its not recommended to overwrite system files unless you are aware of the consequences)

 

I think I will wait then if it's going to get incorporated soon. I'm in no rush to add it but it's always good to know how it's done. Thanks again!

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.