Slack Notification Plugin


(Bernd Ahlers) #1

I created a plugin to notify a Slack channel about new topics in discourse. The source and setup documentation can be found on GitHub:

The plugin has been written against discourse 1.4-beta and is running in our production setup with version 1.3.

Have fun!

WARNING: The plugin does not implement permission checks at the moment. All new topics and all PMs will be posted to the configured channel. See this topic for details.


Integration with Slack?
Event Hooks for Discourse
Put in a vote for Discourse in Zapier apps
Allow Slack to unfurl/expand links to "login-required" Discourse instance
(Tom Newsom) #2

Fantastic! I’ve been looking for something like this. Will install and test asap.
I’m no coder, but by glancing at the source, this looks very extensible. Have you considered adding notifications for other events?

For example, @mentioning a special user (ie. @slack) creates an @channel post in Slack etc


More pressing, however, is some sort of permissions control. This version announces everything in every category, including admin. I’d like to be able to either exclude certain categories, or assign the plugin a username, so the Trust Level and Group membership of that user can affect which categories get watched.

eg


(Kane York) #3

@bernd you will want to do:

guardian = Guardian.new(User.find_by_username(SiteSetting.slack_permissions_username))
# choose one:
# return unless guardian.can_see? post
# return unless guardian.can_see? topic

(Tom Newsom) #4

I’ve turned this off because it forwards everything including PMs. It’s a great start and I hope it grows, but at the moment, the privacy holes are just too big.


(Jeff Atwood) #5

Doesn’t that depend which account you set up with the API key, and what visibility that account has?

I suggest creating an unused “regular” user account with no special privileges as the API key holder in this case.


(Tom Newsom) #6

Can a key be specified on a plugin-by-plugin basis? Because I’d like to have an access-all-areas key as well.


(cpradio) #7

Sort of. Create a new user named ‘slack-notification’ in your Discourse instance, go to the Admin Area > Users > slack-notification > click Generate API Key

Grant the user the permissions to the categories/TLs/Groups you want it to have.


(Bernd Ahlers) #8

Thanks for the heads-up! I will investigate the permission issues.


(DjCyry) #9

Anyone have a demo/image for this ? thx


(Bernd Ahlers) #10

This is how it looks like in slack:

(with a custom discourse emoji configured in slack)


(Bernd Ahlers) #11

I added a warning to my first post in this topic and also to the README in the GitHub repo until the permission problems are fixed.


(Travis) #12

Great idea. I’d love to have this for support categories.


(Avorio) #13

This is great! Indeed, it is much better than the RSS-based integration I had in place before.

Thanks, Bernd!

My suggestions for improvement are:

  • Certainly exclude PMs from these notifications
  • Allow admins to choose the categories that will trigger Slack notifications
  • Enable notifications of posts as well as topics
  • Allow admins to choose between (a) topics-only or (b) topics and posts notifications

Let me know if you need help further defining or testing any of those features.


(Night) #14

I have added these in a pull request that was recently merged in. Category choice isn’t something I personally needed, so someone else can add that if they wish.


(Avorio) #15

Thank you very much for your contributions! Much appreciated :slight_smile:


(RK) #16

Just found this topic. Are the privacy issues fixed now? :slight_smile:


(Dave McClure) #17

Looks like there is an official plugin from Discourse in the works:


(Everett Hamilton) #18

I’m trying to figure out how to get this to post new messages from my discourse into slack. I already installed it as a plugin. The thing that I think might going wrong is between the Slack URL and API key I put a “/”. Here is an example the url and API both are fake. Tell me if this is the right way that it should be done.


Keep in mind it’s a FAKE slack website and API key.
Do I need to setup anything within Slack itself to get this to work? May that be my problem?


(Jeff Atwood) #19

Use the official plugin from Discourse, under the discourse github org.


(Everett Hamilton) #20

Thanks just found it