Set up Slack notifications using the discourse-chat-integration plugin

From what I can tell on the settings, it doesn’t look like there’s a way to send a notifications as a slack PM… is that possible? Or does that need to be developed/implemented?

You should be able to send notifications as a PM by specifying the channel name as something like @jerdog.

Slash commands do not currently work within private channels or private messages, but will do once this PR is merged by the team:

https://github.com/discourse/discourse-chat-integration/pull/20

3 Likes

Is there any way to configure this so that the messages posted in slack are posted by a Bot (other than slackbot)?

Messages are posted by a bot. You can configure the name and picture of the bot in your slack app settings. Notifications look something like this:

1 Like

Hmm, maybe this is just some kind of caching issue with Slack?

Our slack community is called “Envoy”. I can see the correct name when I click on “Envoy” there but ideally the message comes in appearing from “Discourse”.

I will wait a bit and see if it resolves itself.

1 Like

Hi all,

I’ve tried to add slack integration on my Discourse self-hosted app but I’m encountering an error when a new topic is created on a category … When I run a test on my channel rule, I get a “500 error” …

Here is the log I’ve received :
URI::InvalidURIError (can not set host with registry or opaque) /usr/local/lib/ruby/2.4.0/uri/generic.rb:592:in 'check_host'

And here is an extract of the error backtrace :

/usr/local/lib/ruby/2.4.0/uri/generic.rb:592:in 'check_host'
/usr/local/lib/ruby/2.4.0/uri/generic.rb:636:in 'host='
/var/www/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/slack/slack_message_formatter.rb:44:in 'absolute_url'
/var/www/discourse/plugins/discourse-chat-integration/lib/discourse_chat/provider/slack/slack_message_formatter.rb:21:in 'start_element'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/nokogiri-1.8.2/lib/nokogiri/html/sax/parser.rb:36:in 'parse_with' [...]

Has anyone ever had this error?

when i used the slash command from a private channel i.e
#my-special-channel -> /discourse watch site-feedback

the entry in the discourse plugins settings had the channel #privategroup

i.e

works fine if i go and edit the channel name, but this isn’t ideal for users who aren’t also discourse admins :-[

1 Like

A few issues i have had -

  • This gets posted in a channel with name as sakshi. Have I missed some configuration here ?
  • slash commands aren’t working for me. The redirect urls that you have told above

/chat-integration/slack/interactive and command do not seem to be valid :confused:

 curl -vL localhost/chat-integration/slack/command > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ::1...
* connect to ::1 port 80 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /chat-integration/slack/command HTTP/1.1
> Host: localhost
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Thu, 23 Aug 2018 16:57:58 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< X-Request-Id: cf210d9f-4e18-465e-bec5-77f656095a3f
< X-Runtime: 0.027693
<
{ [4703 bytes data]
100  4695    0  4695    0     0   124k      0 --:--:-- --:--:-- --:--:--  127k
* Connection #0 to host localhost left intact

Sorry, the issue was with our server, it is accessible only through our vpn. As slack could not contact the server it raised 503_service_error.

1 Like

when i use slash command on slack channel /discourse status i got error ‘Peer certificate cannot be authenticated with the given CA certificate’ . Kindle provide suggestions asap.

It sounds like Slack doesn’t like the SSL certificate of your Discourse server. Can you share your Discourse URL here?

3 Likes

Hi!

I advertise Discourse using your plugin on our company Slack. :+1:

However I noticed, that unlisted topics are also mentioned by the bot. Could you tweak it to not blurt those without explicit command?

And the same thoughts about not public categories.

Thanks

1 Like

Having an option to prevent posting of unlisted topics sounds like a good idea.

For private categories, you can already control that. See the “Security/Permissions” section of this topic: Chatroom Integration Plugin (discourse-chat-integration)

Thanks for the link.

As I understand, all notifications will be fired using one discourse user. For me that’s a bit rigid. Ideally I need different users for different channels. Our discourse will serve company wide purposes, andalso support projects, which are kind of private.

But, as a workaround / simple solution I can live with a setup, where there are implicit rules like: mute all categories, which are not public. That way if I create a new category for a new project, posts from that new category won’t appear in the company wide channel.

1 Like

Yes, the issue was related to the SSL certificate. It has been solved. Thanks for the immediate help :slight_smile:
Another big thing is, I am embedding the discourse subdomain into our react product. Whenever a user clicks on slack notification of topic/post creation , our intended goal is to redirect user to our product’s domain, instead of discourse subdomain. I am not able to set this redirection. Kindly suggest any way.

I created the slack app as per the instructions. The issue I’m having is that other users want to add notifications to private channels I don’t have access to.
Is there a way to notify private slack channels that the creator of the slack app doesn’t have access too?
Or how can other users grant permissions to the app?

Also if I understand correctly, those slack app tokens that are entered into the Discourse’s plugin configuration allow access to my private channels, correct? This might be undesirable since any Discourse admin can see those tokens in the settings section. Would be good to warn about that, or remove from the instructions the groups:history and im:history grants.

Our makerforums discourse is intended to bring together a lot of related but separate communities. These communities are organized in our discourse by category or sub-category. Some of these communities have their own slack spaces.

At least one community, associated with a sub-category, would like slack integration, but as far as I can tell, there can be only one for the whole discourse.

Am I missing something?

Unfortunately you can only have one slack community connected at the moment. It would be nice to allow multiple connections per-provider in the future.

3 Likes

Thanks for confirming. It looks like it would be substantial work to move to installing arbitrarily many chat integrations, especially to do so without backward compatibility problems.

For anyone else with this problem: As an alternative we are exploring for one-way notification in slack that posts have been made in discourse, we realized that it makes sense to take advantage of Discourse’s RSS support and hook up the slack RSS app:

4 Likes

For the next person who sees this: I saw 422 No Record in the slack integration when trying to send a test message from the admin interface in my discourse.

The logs (https://mydiscourse/logs) showed the real error, which was in my case "{\"ok\":false,\"error\":\"channel_not_found\"}"}

The reason was that /discourse watch in a private channel of the Staff category showed up with a slack channel name like #private instead of the actual channel name, so I had to set the correct channel name in the discourse administrative interface to the actual channel name; then it worked.

2 Likes