# Optionally threading posts to parent topic in slack integration

**URL:** https://meta.discourse.org/t/optionally-threading-posts-to-parent-topic-in-slack-integration/150759
**Category:** Feature
**Tags:** chat-integration
**Created:** [May 7, 2020, 9:33pm UTC](https://meta.discourse.org/t/optionally-threading-posts-to-parent-topic-in-slack-integration/150759 "2020-05-07T21:33:45Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [June 9, 2020, 8:11pm UTC](https://meta.discourse.org/t/optionally-threading-posts-to-parent-topic-in-slack-integration/150759/8 "2020-06-09T20:11:05Z")

</div>

I’ve been thinking about this and reading the [chat.postMessage slack API docs](https://api.slack.com/methods/chat.postMessage), and I believe I can boil down my wall of words to something much simpler.

Only `watch` and not `follow` has the ability to choose threading responses, by a mechanism I’m still trying to determine. Alternatively, @david what would you think of a new `thread` rule filter with precedence `mute` `thread` `watch` `follow`, and plumbing the rule through `trigger_notification` to enable rule-sensitive behavior?

1. If `watch` is configured to thread (alternatively, a `thread` rule is defined), sending a new post notification to a slack channel, if the post topic **has** a slack `ts` associated with it, post to that slack thread by setting `thread_ts` to the provided `ts` value from Slack.

2. When sending a new post notification to a slack channel, and the post topic **does not have** a `ts` associated with it, store the returned response `ts` for the topic (so that future posts on the topic can be threaded if `watch` is configured for threads).

3. When using the `post thread :thread_url` command, store the thread `ts` in the topic that is created, which will be used only by threaded `watch` rules.

Here are my current thoughts and concerns:

1. How to determine whether to post to threads on a per-rule basis. A new filter feels easiest to me at the moment, but maybe I’m missing something.

2. Flowing the original slack post URL and thread ID through the transcript flow is what is most opaque to me right now. This looks like I really need to add a per-provider thread ID somewhere and preserve it until saving the post. I would implement it only for slack `ts` but presumably it won’t be the only chat integration with threads.

3. For posting, I think I need to store the slack `ts` in a slack-specific custom field on Topic, not a general `DiscourseChat` custom thread field.

---

_[View the full topic](https://meta.discourse.org/t/optionally-threading-posts-to-parent-topic-in-slack-integration/150759)._
