Optionally threading posts to parent topic in slack integration

Thanks so much for all your work here @mcdanlj - this is now merged:


I appreciate your very helpful reviews! I updated the official integration wiki post as promised. If you’d prefer to call out the changes in other ways I’m cool with that, no pride of authorship or anything like that. :slight_smile:


Could threading please be enabled within chat-integration Settings for Slack ala

Enable threading of Posts to Slack

You mean, you want to be able to configure the plug-in to refuse to honor the thread option in the integration?

We updated to current 2.6 beta1a tests-pass few days ago, but as far as I can tell no slack x-posts are threaded since the upgrrade. We still see topic posts and replies individually displayed on Slack channels.

Are you saying that you previously had rules that threaded, and with the most recent update you did, it is no longer threading? Or is it that you expected with the update that it would start threading them and it is not doing so?

I’m running discourse 093ee1d80c and discourse-chat-integration da91061 (current up-to-date) and my channel with thread rules is correctly threading responses, only for channels set up with thread rules.

Can you show your configuration for a thread rule? In Admin → Plugins → Chat Integrations you should see rules that say


and if you click on the edit pencil you should see


If you have rules that instead say:


then those rules won’t use threads.

You’ll see above the rationale for this being a per-rule, not per-site, configuration.

When you set up a rule from the /discourse command in slack (or whatever command you chose when you set up the integration), you use thread instead of watch or follow, as documented in Chatroom Integration Plugin (discourse-chat-integration)


Okay, so I need to go through Slack integrations and change every single instance of:
All Posts and Replies < All posts with threaded replies.

So far we are displaying all posts and replies on most channel integration. Will it screw anything up to just display all posts with threaded replies instead moving forward? I also ask because we have a lot of channels for me to re-configure, so best for me to re-assign it properly the first time. :+1:

If I understand your question: No, it won’t “screw anything up” — it’s meant to be safe in that it will never prevent sending a new notification to slack, it’s just that if the integration knows about a thread, it will send it to the thread instead of to the channel. If it’s not aware of a thread context for any reason, then it will send to the channel as configured in the rule.

“All posts with threaded replies” means that:

  • When a new post is added to an existing topic:
    • If a thread ID has been stored for the topic, use it to post a thread
    • If no thread ID has been stored for the topic, after posting the notification to slack, use that new slack post’s thread ID for further posts on the topic. It will start threading from that point on.
  • When a new topic is posted to slack, store its resulting thread ID so that additional posts on that topic are sent to slack as threaded responses.

I summarize that as “act just like watch, except if it knows about a thread to post to, do that instead”

Additionally, when using the “transcript” feature to post slack content as a new topic in Discourse, regardless of any rule settings, it always tries to store the thread ID, so that if a thread rule either already exists or is added in the future, post replies on the new topic in discourse are announced on the appropriate slack thread.

I’m sure your existing rules could be changed with some bin/rails c typing but I don’t want to do that to my live site where I’ve intentionally chosen which channels to thread and which not to, and I’m way too new to ruby to type random ruby as help advice on a forum and expect it not to blow up in your face. :sadpanda: Other than it probably starts with DiscourseChat::Rule.where( I’m not going to be much help. Sorry!


@sunjam by the way, I appreciate the validation that you found this functionality desirable and valuable! (Especially given the irony that I don’t particularly like slack threads myself and did this work for others who find them more valuable than I do!)

I can imagine that it would make sense to add a button to the UI to convert all watch rules to thread rules. However, I don’t actually know enough to do it and wouldn’t use it myself. I’m really a back end developer dabbling in discourse, so I wouldn’t even be a useful reviewer for a PR to add such a button. All I can do is be a feckless cheerleader if someone else wants to implement such functionality. :slight_smile:

1 Like

I found an issue @mcdanlj. When creating a new channel integration: threaded replies does not show up on 2.6 beta1 tests-pass for filters. Once the integration is created, it becomes an option by editing the integration.

I see the same thing now; I hadn’t even noticed the UI for that and I created my rules with slash commands from slack.

To the extent of my limited understanding of front end code, I think this is an artifact of the code @david asked for to hide thread from other integration types:

  available_filters(provider) {
    const available = [];

    if (provider === "slack") {
        id: "thread",
        name: I18n.t("chat_integration.filter.thread"),
        icon: "chevron-right"

I could be wrong.

But I’m really a backend developer and I don’t know how to fix this. I don’t know why the channel.provider would be slack only when editing an existing rule, and not when creating a new one. :grimacing:

I think this should do it:

Let me know if it works for you :slight_smile:


I confirm that it is fixed for me. Thanks @david for cleaning up after what I didn’t know about!

1 Like

@sunjam BTW, after deciding to move most but not all of my slack integration rules from watch to thread, I felt your pain. My eyes definitely glazed over and I was glad to be done. So I’m not sure I would do anything differently in my work, but I don’t diminish the work required to convert. At least it’s a one-time cost.

If there is a one-line command one could run in the rails console to convert all normal watch rules to thread rules, I haven’t figured it out—or I would have used it, and then converted back the few rules that I wanted to keep as watch rules. :slight_smile:


Are thread replies showing up in All Unread and Threads on your Slack side? I’ve seen new posts appear, but thread replies don’t seem to trigger these notifications.

The messages Discourse posts don’t notify differently from any other Slack thread, but this really goes outside discourse into how slack thread notifications work. I think the slack thread notification rules aren’t great, but it’s not like Slack is an open source project that random people can contribute improvements to. You have to participate in or subscribe to a Slack thread to get notifications for additional posts to a thread. At least, that’s the rule this week. I think threads followed channel notification rules when they were first introduced in Slack. I can’t find anything in Slack to enable notifications in threads to follow channels, and it drives me crazy because I miss important information at work as a result.

I dislike Slack’s implementation ot threads so much that it’s truly ironic that I was the one implementing this feature. But I also I think I’m in the minority, and I implemented it to make Discourse more inviting to the majority who really appreciate Slack’s threads.

1 Like

Thank you for the clarification. Seems that those involved in ThreadExample will see the threaded replies, which works well enough. Either way, this is a very useful option in de-cluttering things on the Slack end, plus I hope it will inspire other chat-integrations to incorporate similar variations of this concept!

1 Like

This is true, where “those involved” includes those who pull down the three-vertical-dots menu on the thread, and choose “Follow thread” (the first option).

I just realized there were mock-ups earlier in the thread, but I never shared an example of this in action. So from today on the slack channel for https://forum.makerforums.info/c/k40 we have this:


tried this out for the first time today… pretty dope.


Many thanks to @david for fixing my bug which caused posting transcripts to not honor the thread_id setting and instead posting to the channel!