Hello,
In the channel that uses this bot, we had considered the Slack feature of threading comments.
To do so, you must leverage the properties of a thread of messages - Also called a tree.
For example (messages are numbered for use later, These numbers will be used in place of links),
1 Student 1: I have this question.
2 TA: This is the response to your question
3 Student 1: Please clarify this point
4 TA: Here is clarification
5 Student 1: $Thread_close
When the $thread_close command is issued, the bot will be able to do the following
Take the link to last message in the thread
put the link on a stack
navigate to the link on top of the stack
If the new current message has a link, put it on a stack and recurse. Otherwise, pop the top off the stack and append the message to the transcript.
Using the example conversation above, the bot will construct the stack until it reaches a message with no link.
The stack will look like this (top) {1,2,3,4} (bottom)
the bot will then pop the top, follow link, and append the contents to the transcript until the stack is empty.
Thus the transcript becomes (contents omitted, messages referred to by number from original conversation)
1
2
3
4
This allows for each individual offshoot of a thread to be closed independently. In the context of a tree, this means a leaf node can either spawn a child (a reply to a message in a thread) or decide to stay a leaf (close the thread). Because the action of any leaf is independent of any other leaf, every thread can be closed and have its path from root->the aforementioned leaf node.
For another example - Consider Students 1,2,3 and the TA named "TA". They may have a conversation like so
1: I have a question
2: <Link to 1's question> That reminds me of my question
3: <Link to 1's question> This reminds me of a different question.
TA: <link to 1's last message> Answer to your question
TA: <link to 2's last message> Answer to that question
TA: <Link to 3's last message> Answer to another question
1: $Thread_close <link to the TA's answer to their question>
2: $Thread_Close <link to TA's answer to their question>
3: <Link to TA's answer to their question> Please clarify on your point.
TA: <Link to 3's last message> Here is clarification
3: $Thread_close <link to TA's answer to their request for clarification>.
Thus a tree is created. In the tree, the links were replaced with edges from parent to child. To see the tree, please view the image here: https://i.imgur.com/zw1Opop.jpg
This is each individual transcript that individual users would see
1 -
1: I have a question
TA: <link to 1's last message> Answer to your question
1: $Thread_close <link to the TA's answer to their question>
2 -
1: I have a question
2: <Link to 1's question> That reminds me of my question
TA: <link to 2's last message> Answer to that question
2: $Thread_Close <link to TA's answer to their question>
3 -
1: I have a question
3: <Link to 1's question> This reminds me of a different question.
TA: <Link to 3's last message> Answer to another question
3: <Link to TA's answer to their question> Please clarify on your point.
TA: <Link to 3's last message> Here is clarification
3: $Thread_close <link to TA's answer to their request for clarification>.
I believe I have belabored my point by now. If you have any questions please place them in the comments.