Skip to content

Commit 2da6ca4

Browse files
authored
Added message threads to the docs (#163)
* Added message threading to docs
1 parent fb1fa7a commit 2da6ca4

File tree

13 files changed

+197
-7
lines changed

13 files changed

+197
-7
lines changed

README.rst

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Whether you're building a custom app for your team, or integrating a third party
2121
service into your Slack workflows, Slack Developer Kit for Python allows you to leverage the flexibility
2222
of Python to get your project up and running as quickly as possible.
2323

24+
2425
Requirements and Installation
2526
******************************
2627

@@ -41,6 +42,11 @@ by pulling down the source code directly into your project:
4142
git clone https://github.com/slackapi/python-slackclient.git
4243
pip install -r requirements.txt
4344
45+
Documentation
46+
--------------
47+
48+
For comprehensive method information and usage examples, see the `full documentation <http://slackapi.github.io/python-slackclient>`_.
49+
4450
Getting Help
4551
-------------
4652

@@ -49,11 +55,6 @@ If you get stuck, we’re here to help. The following are the best ways to get a
4955
- Use our `Github Issue Tracker <https://github.com/slackapi/python-slackclient/issues>`_ for reporting bugs or requesting features.
5056
- Visit the `dev4slack channel <http://dev4slack.xoxco.com>`_ for getting help using Slack Developer Kit for Python or just generally bond with your fellow Slack developers.
5157

52-
Documentation
53-
--------------
54-
55-
For comprehensive method information and usage examples, see the `full documentation <http://slackapi.github.io/python-slackclient>`_.
56-
5758
Basic Usage
5859
------------
5960
The Slack Web API allows you to build applications that interact with Slack in more complex ways than the integrations
@@ -89,6 +90,61 @@ There are some unique options specific to sending IMs, so be sure to read the **
8990
section of the `chat.postMessage <https://api.slack.com/methods/chat.postMessage#channels>`_
9091
page for a full list of formatting and authorship options.
9192

93+
94+
Replying to messages and creating threads
95+
********************
96+
Threaded messages are just like regular messages, except thread replies are grouped together to provide greater context
97+
to the user. You can reply to a thread or start a new threaded conversation by simply passing the original message's ``ts``
98+
ID in the ``thread_ts`` attribute when posting a message. If you're replying to a threaded message, you'll pass the `thread_ts`
99+
ID of the message you're replying to.
100+
101+
A channel or DM conversation is a nearly linear timeline of messages exchanged between people, bots, and apps.
102+
When one of these messages is replied to, it becomes the parent of a thread. By default, threaded replies do not
103+
appear directly in the channel, instead relegated to a kind of forked timeline descending from the parent message.
104+
105+
.. code-block:: python
106+
107+
from slackclient import SlackClient
108+
109+
slack_token = os.environ["SLACK_API_TOKEN"]
110+
sc = SlackClient(slack_token)
111+
112+
sc.api_call(
113+
"chat.postMessage",
114+
channel="#python",
115+
text="Hello from Python! :tada:",
116+
thread_ts="1476746830.000003"
117+
)
118+
119+
120+
By default, ``reply_broadcast`` is set to ``False``. To indicate your reply is germane to all members of a channel,
121+
set the ``reply_broadcast`` boolean parameter to ``True``.
122+
123+
.. code-block:: python
124+
125+
from slackclient import SlackClient
126+
127+
slack_token = os.environ["SLACK_API_TOKEN"]
128+
sc = SlackClient(slack_token)
129+
130+
sc.api_call(
131+
"chat.postMessage",
132+
channel="#python",
133+
text="Hello from Python! :tada:",
134+
thread_ts="1476746830.000003",
135+
reply_broadcast=True
136+
)
137+
138+
139+
**Note:** While threaded messages may contain attachments and message buttons, when your reply is broadcast to the
140+
channel, it'll actually be a reference to your reply, not the reply itself.
141+
So, when appearing in the channel, it won't contain any attachments or message buttons. Also note that updates and
142+
deletion of threaded replies works the same as regular messages.
143+
144+
See the `Threading messages together <https://api.slack.com/docs/message-threading#forking_conversations>`_
145+
article for more information.
146+
147+
92148
Deleting a message
93149
********************
94150
Sometimes you need to delete things.

docs-src/basic_usage.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,62 @@ There are some unique options specific to sending IMs, so be sure to read the **
3838
section of the `chat.postMessage <https://api.slack.com/methods/chat.postMessage#channels>`_
3939
page for a full list of formatting and authorship options.
4040

41+
--------
42+
43+
Replying to messages and creating threads
44+
-----------------------
45+
Threaded messages are just like regular messages, except thread replies are grouped together to provide greater context
46+
to the user. You can reply to a thread or start a new threaded conversation by simply passing the original message's ``ts``
47+
ID in the ``thread_ts`` attribute when posting a message. If you're replying to a threaded message, you'll pass the `thread_ts`
48+
ID of the message you're replying to.
49+
50+
A channel or DM conversation is a nearly linear timeline of messages exchanged between people, bots, and apps.
51+
When one of these messages is replied to, it becomes the parent of a thread. By default, threaded replies do not
52+
appear directly in the channel, instead relegated to a kind of forked timeline descending from the parent message.
53+
54+
.. code-block:: python
55+
56+
from slackclient import SlackClient
57+
58+
slack_token = os.environ["SLACK_API_TOKEN"]
59+
sc = SlackClient(slack_token)
60+
61+
sc.api_call(
62+
"chat.postMessage",
63+
channel="#python",
64+
text="Hello from Python! :tada:",
65+
thread_ts="1476746830.000003"
66+
)
67+
68+
69+
By default, ``reply_broadcast`` is set to ``False``. To indicate your reply is germane to all members of a channel,
70+
set the ``reply_broadcast`` boolean parameter to ``True``.
71+
72+
.. code-block:: python
73+
74+
from slackclient import SlackClient
75+
76+
slack_token = os.environ["SLACK_API_TOKEN"]
77+
sc = SlackClient(slack_token)
78+
79+
sc.api_call(
80+
"chat.postMessage",
81+
channel="#python",
82+
text="Hello from Python! :tada:",
83+
thread_ts="1476746830.000003",
84+
reply_broadcast=True
85+
)
86+
87+
88+
**Note:** While threaded messages may contain attachments and message buttons, when your reply is broadcast to the
89+
channel, it'll actually be a reference to your reply, not the reply itself.
90+
So, when appearing in the channel, it won't contain any attachments or message buttons. Also note that updates and
91+
deletion of threaded replies works the same as regular messages.
92+
93+
See the `Threading messages together <https://api.slack.com/docs/message-threading#forking_conversations>`_
94+
article for more information.
95+
96+
4197
--------
4298

4399
Updating the content of a message

docs/about.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>
@@ -77,6 +78,9 @@
7778
</ul>
7879
</li>
7980
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a><ul>
81+
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v1-0-4-2016-12-15">v1.0.4 (2016-12-15)</a></li>
82+
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v1-0-3-2016-12-13">v1.0.3 (2016-12-13)</a></li>
83+
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v1-0-2-2016-09-22">v1.0.2 (2016-09-22)</a></li>
8084
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v1-0-1-2016-03-25">v1.0.1 (2016-03-25)</a></li>
8185
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v1-0-0-2016-02-28">v1.0.0 (2016-02-28)</a></li>
8286
<li class="toctree-l2"><a class="reference internal" href="changelog.html#v0-18-0-2016-02-21">v0.18.0 (2016-02-21)</a></li>

docs/auth.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>
@@ -217,7 +218,7 @@ <h2>The OAuth flow<a class="headerlink" href="#the-oauth-flow" title="Permalink
217218
user access token instead of the top-level access token granted to your application.</p>
218219
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Save the bot token to an environmental variable or to your data store</span>
219220
<span class="c1"># for later use</span>
220-
<span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_USER_TOKEN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">auth_response</span><span class="p">[</span><span class="s1">&#39;user_access_token&#39;</span><span class="p">]</span>
221+
<span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_USER_TOKEN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">auth_response</span><span class="p">[</span><span class="s1">&#39;access_token&#39;</span><span class="p">]</span>
221222
<span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_BOT_TOKEN&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">auth_response</span><span class="p">[</span><span class="s1">&#39;bot&#39;</span><span class="p">][</span><span class="s1">&#39;bot_access_token&#39;</span><span class="p">]</span>
222223

223224
<span class="c1"># Don&#39;t forget to let the user know that auth has succeeded!</span>

docs/basic_usage.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1 current"><a class="current reference internal" href="#">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>
@@ -146,6 +147,52 @@ <h2>Sending a message<a class="headerlink" href="#sending-a-message" title="Perm
146147
page for a full list of formatting and authorship options.</p>
147148
</div>
148149
<hr class="docutils" />
150+
<div class="section" id="replying-to-messages-and-creating-threads">
151+
<h2>Replying to messages and creating threads<a class="headerlink" href="#replying-to-messages-and-creating-threads" title="Permalink to this headline"></a></h2>
152+
<p>Threaded messages are just like regular messages, except thread replies are grouped together to provide greater context
153+
to the user. You can reply to a thread or start a new threaded conversation by simply passing the original message&#8217;s <code class="docutils literal"><span class="pre">ts</span></code>
154+
ID in the <code class="docutils literal"><span class="pre">thread_ts</span></code> attribute when posting a message. If you&#8217;re replying to a threaded message, you&#8217;ll pass the <cite>thread_ts</cite>
155+
ID of the message you&#8217;re replying to.</p>
156+
<p>A channel or DM conversation is a nearly linear timeline of messages exchanged between people, bots, and apps.
157+
When one of these messages is replied to, it becomes the parent of a thread. By default, threaded replies do not
158+
appear directly in the channel, instead relegated to a kind of forked timeline descending from the parent message.</p>
159+
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">slackclient</span> <span class="kn">import</span> <span class="n">SlackClient</span>
160+
161+
<span class="n">slack_token</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_API_TOKEN&quot;</span><span class="p">]</span>
162+
<span class="n">sc</span> <span class="o">=</span> <span class="n">SlackClient</span><span class="p">(</span><span class="n">slack_token</span><span class="p">)</span>
163+
164+
<span class="n">sc</span><span class="o">.</span><span class="n">api_call</span><span class="p">(</span>
165+
<span class="s2">&quot;chat.postMessage&quot;</span><span class="p">,</span>
166+
<span class="n">channel</span><span class="o">=</span><span class="s2">&quot;#python&quot;</span><span class="p">,</span>
167+
<span class="n">text</span><span class="o">=</span><span class="s2">&quot;Hello from Python! :tada:&quot;</span><span class="p">,</span>
168+
<span class="n">thread_ts</span><span class="o">=</span><span class="s2">&quot;1476746830.000003&quot;</span>
169+
<span class="p">)</span>
170+
</pre></div>
171+
</div>
172+
<p>By default, <code class="docutils literal"><span class="pre">reply_broadcast</span></code> is set to <code class="docutils literal"><span class="pre">False</span></code>. To indicate your reply is germane to all members of a channel,
173+
set the <code class="docutils literal"><span class="pre">reply_broadcast</span></code> boolean parameter to <code class="docutils literal"><span class="pre">True</span></code>.</p>
174+
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">slackclient</span> <span class="kn">import</span> <span class="n">SlackClient</span>
175+
176+
<span class="n">slack_token</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_API_TOKEN&quot;</span><span class="p">]</span>
177+
<span class="n">sc</span> <span class="o">=</span> <span class="n">SlackClient</span><span class="p">(</span><span class="n">slack_token</span><span class="p">)</span>
178+
179+
<span class="n">sc</span><span class="o">.</span><span class="n">api_call</span><span class="p">(</span>
180+
<span class="s2">&quot;chat.postMessage&quot;</span><span class="p">,</span>
181+
<span class="n">channel</span><span class="o">=</span><span class="s2">&quot;#python&quot;</span><span class="p">,</span>
182+
<span class="n">text</span><span class="o">=</span><span class="s2">&quot;Hello from Python! :tada:&quot;</span><span class="p">,</span>
183+
<span class="n">thread_ts</span><span class="o">=</span><span class="s2">&quot;1476746830.000003&quot;</span><span class="p">,</span>
184+
<span class="n">reply_broadcast</span><span class="o">=</span><span class="bp">True</span>
185+
<span class="p">)</span>
186+
</pre></div>
187+
</div>
188+
<p><strong>Note:</strong> While threaded messages may contain attachments and message buttons, when your reply is broadcast to the
189+
channel, it&#8217;ll actually be a reference to your reply, not the reply itself.
190+
So, when appearing in the channel, it won&#8217;t contain any attachments or message buttons. Also note that updates and
191+
deletion of threaded replies works the same as regular messages.</p>
192+
<p>See the <a class="reference external" href="https://api.slack.com/docs/message-threading#forking_conversations">Threading messages together</a>
193+
article for more information.</p>
194+
</div>
195+
<hr class="docutils" />
149196
<div class="section" id="updating-the-content-of-a-message">
150197
<h2>Updating the content of a message<a class="headerlink" href="#updating-the-content-of-a-message" title="Permalink to this headline"></a></h2>
151198
<p>Let&#8217;s say you have a bot which posts the status of a request. When that request

docs/changelog.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>

docs/faq.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>

docs/genindex.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
</li>
5454
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5555
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
56+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5859
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>

docs/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</li>
5353
<li class="toctree-l1"><a class="reference internal" href="basic_usage.html">Basic Usage</a><ul>
5454
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#sending-a-message">Sending a message</a></li>
55+
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#replying-to-messages-and-creating-threads">Replying to messages and creating threads</a></li>
5556
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#updating-the-content-of-a-message">Updating the content of a message</a></li>
5657
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#deleting-a-message">Deleting a message</a></li>
5758
<li class="toctree-l2"><a class="reference internal" href="basic_usage.html#adding-or-removing-an-emoji-reaction">Adding or removing an emoji reaction</a></li>

0 commit comments

Comments
 (0)