You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs-src/real_time_messaging.rst
+8-31Lines changed: 8 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,9 @@ RTM Client
8
8
Real Time Messaging (RTM)
9
9
---------------------------------------
10
10
11
+
.. parsed-literal ::
12
+
**rtm.start method has been deprecated for apps created after Nov 30th, 2021.** See details `here <https://api.slack.com/changelog/2021-10-rtm-start-to-stop>`_
13
+
11
14
The `Real Time Messaging (RTM) API`_ is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users.
12
15
13
16
If you prefer events to be pushed to your app, we recommend using the HTTP-based `Events API <https://api.slack.com/events-api>`_ along with `Socket Mode <https://api.slack.com/socket-mode>`_ instead. The Events API contains some events that aren't supported in the RTM API (like `app_home_opened event <https://api.slack.com/events/app_home_opened>`_), and it supports most of the event types in the RTM API. If you'd like to use the Events API, you can use the `Python Slack Events Adaptor <https://github.com/slackapi/python-slack-events-api>`_.
@@ -50,7 +53,7 @@ Note that the import here is not ``from slack_sdk.rtm import RTMClient`` but ``f
50
53
thread_ts=thread_ts
51
54
)
52
55
53
-
rtm.start()
56
+
rtm.connect()
54
57
55
58
56
59
**Connecting to the RTM API (v1 client)**
@@ -80,40 +83,14 @@ Below is a code snippet that uses the legacy version of ``RTMClient``. For new a
80
83
81
84
slack_token = os.environ["SLACK_BOT_TOKEN"]
82
85
rtm_client = RTMClient(token=slack_token)
83
-
rtm_client.start()
86
+
rtm_client.connect()
84
87
85
88
**rtm.start vs rtm.connect (v1 client)**
86
89
87
-
By default, the RTM client uses ``rtm.connect`` to establish a WebSocket connection with Slack. The response contains basic information about the team and WebSocket url.
88
-
89
-
If you'd rather use ``rtm.start`` to establish the connection, which provides more information about the conversations and users on the team, you can set the ``connect_method`` option to ``rtm.start`` when instantiating the RTM Client. Note that on larger teams, use of ``rtm.start`` can be slow and unreliable.
90
-
91
-
.. code-block:: python
92
-
93
-
import os
94
-
from slack_sdk.rtm import RTMClient
95
-
96
-
@RTMClient.run_on(event="message")
97
-
defsay_hello(**payload):
98
-
data = payload['data']
99
-
web_client = payload['web_client']
100
-
if'text'in data and'Hello'in data['text']:
101
-
channel_id = data['channel']
102
-
thread_ts = data['ts']
103
-
user = data['user'] # This is not username but user ID (the format is either U*** or W***)
104
-
105
-
web_client.chat_postMessage(
106
-
channel=channel_id,
107
-
text=f"Hi <@{user}>!",
108
-
thread_ts=thread_ts
109
-
)
90
+
.. parsed-literal ::
91
+
**rtm.start method has been deprecated for apps created after Nov 30th, 2021.** See details `here <https://api.slack.com/changelog/2021-10-rtm-start-to-stop>`_
110
92
111
-
slack_token = os.environ["SLACK_BOT_TOKEN"]
112
-
rtm_client = RTMClient(
113
-
token=slack_token,
114
-
connect_method='rtm.start'
115
-
)
116
-
rtm_client.start()
93
+
By default, the RTM client uses ``rtm.connect`` to establish a WebSocket connection with Slack. The response contains basic information about the team and WebSocket url.
117
94
118
95
Read the `rtm.connect docs <https://api.slack.com/methods/rtm.connect>`_ and the `rtm.start docs <https://api.slack.com/methods/rtm.start>`_ for more details. Also, note that ``slack.rtm_v2.RTMClient`` does not support ``rtm.start``.
Copy file name to clipboardExpand all lines: docs/real_time_messaging.html
+4-29Lines changed: 4 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,7 @@
215
215
<spanid="real-time-messaging"></span><h1>RTM Client<aclass="headerlink" href="#rtm-client" title="Permalink to this heading">¶</a></h1>
216
216
<sectionid="real-time-messaging-rtm">
217
217
<h2>Real Time Messaging (RTM)<aclass="headerlink" href="#real-time-messaging-rtm" title="Permalink to this heading">¶</a></h2>
218
+
<preclass="literal-block"><strong>rtm.start method deprecation after Nov 30th, 2021.</strong> see details <aclass="reference external" href="https://api.slack.com/changelog/2021-10-rtm-start-to-stop">here</a></pre>
218
219
<p>The <aclass="reference external" href="https://api.slack.com/rtm">Real Time Messaging (RTM) API</a> is a WebSocket-based API that allows you to receive events from Slack in real time and send messages as users.</p>
219
220
<p>If you prefer events to be pushed to your app, we recommend using the HTTP-based <aclass="reference external" href="https://api.slack.com/events-api">Events API</a> along with <aclass="reference external" href="https://api.slack.com/socket-mode">Socket Mode</a> instead. The Events API contains some events that aren’t supported in the RTM API (like <aclass="reference external" href="https://api.slack.com/events/app_home_opened">app_home_opened event</a>), and it supports most of the event types in the RTM API. If you’d like to use the Events API, you can use the <aclass="reference external" href="https://github.com/slackapi/python-slack-events-api">Python Slack Events Adaptor</a>.</p>
220
221
<p>The RTMClient allows apps to communicate with the Slack Platform’s RTM API.</p>
@@ -244,7 +245,7 @@ <h2>Real Time Messaging (RTM)<a class="headerlink" href="#real-time-messaging-rt
<p><strong>rtm.start vs rtm.connect (v1 client)</strong></p>
278
+
<preclass="literal-block"><strong>rtm.start method deprecation after Nov 30th, 2021.</strong> see details <aclass="reference external" href="https://api.slack.com/changelog/2021-10-rtm-start-to-stop">here</a></pre>
277
279
<p>By default, the RTM client uses <codeclass="docutils literal notranslate"><spanclass="pre">rtm.connect</span></code> to establish a WebSocket connection with Slack. The response contains basic information about the team and WebSocket url.</p>
278
-
<p>If you’d rather use <codeclass="docutils literal notranslate"><spanclass="pre">rtm.start</span></code> to establish the connection, which provides more information about the conversations and users on the team, you can set the <codeclass="docutils literal notranslate"><spanclass="pre">connect_method</span></code> option to <codeclass="docutils literal notranslate"><spanclass="pre">rtm.start</span></code> when instantiating the RTM Client. Note that on larger teams, use of <codeclass="docutils literal notranslate"><spanclass="pre">rtm.start</span></code> can be slow and unreliable.</p>
<spanclass="n">user</span><spanclass="o">=</span><spanclass="n">data</span><spanclass="p">[</span><spanclass="s1">'user'</span><spanclass="p">]</span><spanclass="c1"># This is not username but user ID (the format is either U*** or W***)</span>
<p>Read the <aclass="reference external" href="https://api.slack.com/methods/rtm.connect">rtm.connect docs</a> and the <aclass="reference external" href="https://api.slack.com/methods/rtm.start">rtm.start docs</a> for more details. Also, note that <codeclass="docutils literal notranslate"><spanclass="pre">slack.rtm_v2.RTMClient</span></code> does not support <codeclass="docutils literal notranslate"><spanclass="pre">rtm.start</span></code>.</p>
0 commit comments