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

Hey folks, I’m looking to get this configured for a place that has some tighter security restrictions. In reviewing the required scopes documented in the OP vs. what is currently allowed, this is what I see:

chat:write # ? unclear, but chat:write:bot is OK
chat:write.customize ? unclear, but chat:write:bot is OK
users:read # X rejected
channels:history X rejected
groups:history # OK, cautiously accepted
im:history # OK, accepted

If the app were only configured with the following scopes, what would work and what would be broken?

chat:write:bot
groups:history
im:history

For example, I would be OK giving up transcripts…

3 Likes

It’s been a while since I first implemented this, and it looks like slack’s scopes have changed a lot since then. I see people have been keeping the OP wiki up-to-date, which is great! :heart_eyes:

I think that chat:write:bot and chat:write:user have been deprecated in favour of chat:write.

It looks like chat:write.customize is required because we customize the message’s author_name and author_icon to match the Discourse user.

The users:read and *:history scopes are only used for the transcript posting. I realise it seems like a lot! But fundamentally Discourse needs access to your chat history in order to build the transcript. If you’d rather not grant those permissions then it should be totally fine to skip them, and continue without transcript posting.

4 Likes

When I use slash commands, I get this error: /hub failed with the error "dispatch_failed"

(We use /hub instead of /discourse)

I have been able to add the app to the channel. I’ve also been able to send a test post from Discourse to our Slack, but I haven’t been able to figure out the / commands. I’d love some help troubleshooting!

Can you check the permissions that you have added to the app on Slack? The last time I tried configuring this, all the permissions from steps 5 and 6 of the guide needed to be added to the Apps scopes:

  • chat:write
  • chat:write.customize
  • users:read
  • channels:history
  • groups:history
  • im:history

Let us know if that doesn’t resolve the issue.

1 Like

I believe I do have the correct permissions. Here’s a screenshot of the settings I have under Bot Token Scopes.

What do you think? Unfortunately that means something else is going on.

2 Likes

I’ve gone through the setup guide again and created a /hub slash command. Calling /hub post is working for me on any channels that I’ve added the app to. I am using the same permissions as in the screenshot that you posted.

Can you make sure you’ve completed step 8 of the guide? That section tells you to:

Go to the Interactivity & Shortcuts page, enable the Interactivity section by switching it to On and enter this url under “Request URL”

<your-discourse-url>/chat-integration/slack/interactive

It might also be good to confirm that you can post from Discourse to the Slack channel that you’re trying to run the /hub post command on.

Let us know if you’re still not able to get this to work.

1 Like

I checked and I believe yes, I did follow that step.

Here’s a screenshot.

I think the error is happening in something related to Step 7, though.

Here are my settings.

How that shows up when I try using the slash command on Slack is

Yes, that part is working perfectly.

Nope, not working. :slightly_smiling_face:

1 Like

The “Request URL” in the Edit Command section of your screenshot isn’t using HTTPS. Maybe that’s the problem.

2 Likes

That did it, thank you!!!

1 Like

I’ve followed the instructions in this guide and have my Disourse/Slack integration (mostly) working. Great work on this plugin! I do have three questions/observations.

Can’t subscribe to messages in a sub category by subscribing to the parent

This may be by-design, but it wasn’t obvious at first. I have parent categories with child categories under them. I expected that if I created a rule that filtered “All posts and replies” to the parent category that it would implicitly include each of the children categories as well. This did not seem to work however, and I needed to create rules for each of my (many) child categories. This would be a great enhancement request to simplify setup for a Discourse installation with many sub categories under a few parent categories.

Can’t subscribe to all categories with a single rule

I found some conflicting information on this and I assume the older Slack plugin allowed for this, but I couldn’t find a way to create a single rule that would simply subscript to all posts and replies from ALL categories in the site. I was hoping to do this all in a single, simple rule. But due to this and the point above, it took 31 separate rules instead of a single rule to just get a basic bridge between my entire Discourse platform and a Slack channel. Unless I’ve missed something, please consider this as an enhancement request as well.

Discourse post command only works in one channel

Now, this is likely my fault, but I can’t figure it out, I’ve been through all the threads on the topic, and I’d love some help. I’ve checked and doubled checked the permissions of my Slack app and I can confirm that it totally 100% works… in only one of my channels!

/discourse post 20

So I know the access token is set up and working fine. However, in all of the other channels in my Slack team, the command above simply outputs

Loading the transcript...

and that’s all. These are all public channels and I’ve tried every manner of combination of settings. The one channel that works was created newly today, but when I created another new channel to test, it didn’t work. I don’t even know where to begin troubleshooting this. The only logs I’m aware of in Discourse are

./launcher logs app

but there doesn’t seem to be anything at all there. What setting may I have overlooked that would only allow posting to work in one channel, and where would I look to debug this?

Thanks for the guide!

Like an earlier poster, I’m hitting these errors:

/discourse failed with the error "dispatch_failed"

image

What might I be missing? I double checked the information that I’ve pasted screenshots of below.

Are there debug logs available for this? I checked Error Logs in Admin, and also sudo ./launcher logs app.

Please let me know what additional info I can provide to help debug this. Thank you!


Oauth scopes:

Slash command params

Verification & Oauth tokens

image

Interactivity settings

image

@stanislaw after you first asked and David responded, I implemented threaded replies, with David’s advice.

That topic shows how to configure it.

2 Likes

@Brad_Wood your suggestions and question sound interesting, so I don’t want them to get lost.

Would you mind moving the first 2 as a new topic in #feature and tag it #chat-integration, then moving your question to #support a d tag it #chat-integration too?

This would make it easier to follow/track and not get lost here.

I would have moved the post to a new topic for you, but seeing as you have feature requests and a question in the single post, I’d have to edit and create something new to move it, and I don’t want to do that.

2 Likes

@osioke I have created two new topics as you requested, however it appears I don’t have permissions to add tags.

If you could help me tag these posts or let me know how to tag them, I would appreciate the assistance.

1 Like

Hi, I was running into this same issue (after following the steps exactly).

The thing that I was missing was enabling the top level chat integration plugin:

Enabling this got the integration to work as expected.

3 Likes

@ililic Thank you! That was it. :man_facepalming:

(Would be good to explicitly add this to the top-level instructions! @david)

Good idea :+1: I added it to the first step in the OP here:

3 Likes

What is the best way to set the bot to send Slack notification for ALL posts/replies in the forum?

Currently it seems that first you have to add all different topics separately and it still doesn’t work if someone posts in the subcategory of those topics.

A really odd thing happens when chat-integration is paired with DiscoTOC - automatic table of contents (cc @Johani)

The headings are now preceded by a link that does NOT go to the heading.

See screenshots below.
The original post

The preview in Slack

Result of clicking on the first link is just the homepage of the forum

1 Like