jedimstr

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.

Share this post


Link to post
Share on other sites

+1 on this. Slack is slowly becoming a centralized place for not only my work communications, but personal as well. unRAID would be great to have in there.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

 

1) ¯\_( )_/¯

 

2) Drop a PNG logo here: /usr/local/emhttp/webGui/icons

Share this post


Link to post
Share on other sites

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

 

This is stored on your flash device under folder /config/plugins/dynamix/notifications/agents

Share this post


Link to post
Share on other sites

You should contact @Squid and make a plugin for this for the Community Applications

  • Upvote 1

Share this post


Link to post
Share on other sites
On 3/22/2017 at 11:45 AM, kizer said:

You should contact @Squid and make a plugin for this for the Community Applications

 

+1

Share this post


Link to post
Share on other sites

Wouldn't something like this be better off as an included Notification than a plugin in CA?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Posted (edited)
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Thanks for the inspiration. This works great :)

 

Hoping for an official integration in the future. I really started like Slack for both chatting and notifications.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.