Skip to content

Commit 6337ddd

Browse files
committed
chore: merge w main
2 parents e808aba + 9624808 commit 6337ddd

File tree

117 files changed

+12513
-5931
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+12513
-5931
lines changed

.github/ISSUE_TEMPLATE/03_document.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ assignees: ""
1010

1111
### The page URLs
1212

13-
- https://slack.dev/python-slack-sdk/
13+
- https://docs.slack.dev/tools/python-slack-sdk/
1414

1515
### Requirements
1616

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ Whether you're building a custom app for your team, or integrating a third party
2727
The **Python Slack SDK** allows interaction with:
2828

2929
- `slack_sdk.web`: for calling the [Web API methods][api-methods]
30-
- `slack_sdk.webhook`: for utilizing the [Incoming Webhooks](https://api.slack.com/messaging/webhooks) and [`response_url`s in payloads](https://api.slack.com/interactivity/handling#message_responses)
31-
- `slack_sdk.signature`: for [verifying incoming requests from the Slack API server](https://api.slack.com/authentication/verifying-requests-from-slack)
32-
- `slack_sdk.socket_mode`: for receiving and sending messages over [Socket Mode](https://api.slack.com/socket-mode) connections
33-
- `slack_sdk.audit_logs`: for utilizing [Audit Logs APIs](https://api.slack.com/admins/audit-logs)
34-
- `slack_sdk.scim`: for utilizing [SCIM APIs](https://api.slack.com/admins/scim)
35-
- `slack_sdk.oauth`: for implementing the [Slack OAuth flow](https://api.slack.com/authentication/oauth-v2)
36-
- `slack_sdk.models`: for constructing [Block Kit](https://api.slack.com/block-kit) UI components using easy-to-use builders
30+
- `slack_sdk.webhook`: for utilizing the [Incoming Webhooks](https://docs.slack.dev/messaging/sending-messages-using-incoming-webhooks/) and [`response_url`s in payloads](https://docs.slack.dev/interactivity/handling-user-interaction/#message_responses)
31+
- `slack_sdk.signature`: for [verifying incoming requests from the Slack API server](https://docs.slack.dev/authentication/verifying-requests-from-slack/)
32+
- `slack_sdk.socket_mode`: for receiving and sending messages over [Socket Mode](https://docs.slack.dev/apis/events-api/using-socket-mode/) connections
33+
- `slack_sdk.audit_logs`: for utilizing [Audit Logs APIs](https://docs.slack.dev/admins/audit-logs-api/)
34+
- `slack_sdk.scim`: for utilizing [SCIM APIs](https://docs.slack.dev/admins/scim-api/)
35+
- `slack_sdk.oauth`: for implementing the [Slack OAuth flow](https://docs.slack.dev/authentication/installing-with-oauth/)
36+
- `slack_sdk.models`: for constructing [Block Kit](https://docs.slack.dev/block-kit/) UI components using easy-to-use builders
3737
- `slack_sdk.rtm`: for utilizing the [RTM API][rtm-docs]
3838

3939
If you want to use our [Events API][events-docs] and Interactivity features, please check the [Bolt for Python][bolt-python] library. Details on the Tokens and Authentication can be found in our [Auth Guide](https://docs.slack.dev/tools/python-slack-sdk/installation/).
@@ -293,9 +293,9 @@ helpful and collaborative way.
293293
<!-- Markdown links -->
294294

295295
[slackclientv1]: https://github.com/slackapi/python-slackclient/tree/v1
296-
[api-methods]: https://api.slack.com/methods
297-
[rtm-docs]: https://api.slack.com/rtm
298-
[events-docs]: https://api.slack.com/events-api
296+
[api-methods]: https://docs.slack.dev/reference/methods
297+
[rtm-docs]: https://docs.slack.dev/legacy/legacy-rtm-api/
298+
[events-docs]: https://docs.slack.dev/apis/events-api/
299299
[bolt-python]: https://github.com/slackapi/bolt-python
300300
[pypi]: https://pypi.org/
301301
[gh-issues]: https://github.com/slackapi/python-slack-sdk/issues

docs/english/web.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ except SlackApiError as e:
3333
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
3434
```
3535

36+
### Sending ephemeral messages
37+
3638
Sending an ephemeral message, which is only visible to an assigned user in a specified channel, is nearly the same as sending a regular message but with an additional `user` parameter.
3739

3840
``` python
@@ -51,6 +53,114 @@ response = client.chat_postEphemeral(
5153

5254
See the [`chat.postEphemeral`](/reference/methods/chat.postEphemeral) API method for more details.
5355

56+
### Sending streaming messages {#sending-streaming-messages}
57+
58+
You can have your app's messages stream in to replicate conventional AI chatbot behavior. This is done through three Web API methods:
59+
60+
* [`chat_startStream`](/reference/methods/chat.startstream)
61+
* [`chat_appendStream`](/reference/methods/chat.appendstream)
62+
* [`chat_stopStream`](/reference/methods/chat.stopstream)
63+
64+
:::tip[The Python Slack SDK provides a [`chat_stream()`](https://docs.slack.dev/tools/python-slack-sdk/reference/web/client.html#slack_sdk.web.client.WebClient.chat_stream) helper utility to streamline calling these methods.]
65+
66+
See the [_Streaming messages_](/tools/bolt-python/concepts/message-sending#streaming-messages) section of the Bolt for Python docs for implementation instructions.
67+
68+
:::
69+
70+
#### Starting the message stream {#starting-stream}
71+
72+
First you need to begin the message stream:
73+
74+
```python
75+
# Example: Stream a response to any message
76+
@app.message()
77+
def handle_message(message, client):
78+
channel_id = event.get("channel")
79+
team_id = event.get("team")
80+
thread_ts = event.get("thread_ts") or event.get("ts")
81+
user_id = event.get("user")
82+
83+
# Start a new message stream
84+
stream_response = client.chat_startStream(
85+
channel=channel_id,
86+
recipient_team_id=team_id,
87+
recipient_user_id=user_id,
88+
thread_ts=thread_ts,
89+
)
90+
stream_ts = stream_response["ts"]
91+
```
92+
93+
#### Appending content to the message stream {#appending-stream}
94+
95+
With the stream started, you can then append text to it in chunks to convey a streaming effect.
96+
97+
The structure of the text coming in will depend on your source. The following code snippet uses OpenAI's response structure as an example:
98+
99+
```python
100+
# continued from above
101+
for event in returned_message:
102+
if event.type == "response.output_text.delta":
103+
client.chat_appendStream(
104+
channel=channel_id,
105+
ts=stream_ts,
106+
markdown_text=f"{event.delta}"
107+
)
108+
else:
109+
continue
110+
```
111+
112+
#### Stopping the message stream {#stopping-stream}
113+
114+
Your app can then end the stream with the `chat_stopStream` method:
115+
116+
```python
117+
# continued from above
118+
client.chat_stopStream(
119+
channel=channel_id,
120+
ts=stream_ts
121+
)
122+
```
123+
124+
The method also provides you an opportunity to request user feedback on your app's responses using the [feedback buttons](/reference/block-kit/block-elements/feedback-buttons-element) block element within the [context actions](/reference/block-kit/blocks/context-actions-block) block. The user will be presented with thumbs up and thumbs down buttons which send an action to your app when pressed.
125+
126+
```python
127+
def create_feedback_block() -> List[Block]:
128+
blocks: List[Block] = [
129+
ContextActionsBlock(
130+
elements=[
131+
FeedbackButtonsElement(
132+
action_id="feedback",
133+
positive_button=FeedbackButtonObject(
134+
text="Good Response",
135+
accessibility_label="Submit positive feedback on this response",
136+
value="good-feedback",
137+
),
138+
negative_button=FeedbackButtonObject(
139+
text="Bad Response",
140+
accessibility_label="Submit negative feedback on this response",
141+
value="bad-feedback",
142+
),
143+
)
144+
]
145+
)
146+
]
147+
return blocks
148+
149+
@app.message()
150+
def handle_message(message, client):
151+
# ... previous streaming code ...
152+
153+
# Stop the stream and add interactive elements
154+
feedback_block = create_feedback_block()
155+
client.chat_stopStream(
156+
channel=channel_id,
157+
ts=stream_ts,
158+
blocks=feedback_block
159+
)
160+
```
161+
162+
See [Formatting messages with Block Kit](#block-kit) below for more details on using Block Kit with messages.
163+
54164
## Formatting messages with Block Kit {#block-kit}
55165

56166
Messages posted from apps can contain more than just text; they can also include full user interfaces composed of blocks using [Block Kit](/block-kit).

docs/reference/audit_logs/async_client.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8787
retry_handlers: Optional[List[AsyncRetryHandler]] = None,
8888
):
8989
&#34;&#34;&#34;API client for Audit Logs API
90-
See https://api.slack.com/admins/audit-logs for more details
90+
See https://docs.slack.dev/admins/audit-logs-api/ for more details
9191

9292
Args:
9393
token: An admin user&#39;s token, which starts with `xoxp-`
@@ -389,7 +389,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
389389
return resp</code></pre>
390390
</details>
391391
<div class="desc"><p>API client for Audit Logs API
392-
See <a href="https://api.slack.com/admins/audit-logs">https://api.slack.com/admins/audit-logs</a> for more details</p>
392+
See <a href="https://docs.slack.dev/admins/audit-logs-api/">https://docs.slack.dev/admins/audit-logs-api/</a> for more details</p>
393393
<h2 id="args">Args</h2>
394394
<dl>
395395
<dt><strong><code>token</code></strong></dt>

docs/reference/audit_logs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 class="title">Module <code>slack_sdk.audit_logs</code></h1>
3737
</header>
3838
<section id="section-intro">
3939
<p>Audit Logs API is a set of APIs for monitoring what’s happening in your Enterprise Grid organization.</p>
40-
<p>Refer to <a href="https://slack.dev/python-slack-sdk/audit-logs/">https://slack.dev/python-slack-sdk/audit-logs/</a> for details.</p>
40+
<p>Refer to <a href="https://docs.slack.dev/tools/python-slack-sdk/audit-logs">https://docs.slack.dev/tools/python-slack-sdk/audit-logs</a> for details.</p>
4141
</section>
4242
<section>
4343
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
@@ -94,7 +94,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9494
retry_handlers: Optional[List[RetryHandler]] = None,
9595
):
9696
&#34;&#34;&#34;API client for Audit Logs API
97-
See https://api.slack.com/admins/audit-logs for more details
97+
See https://docs.slack.dev/admins/audit-logs-api/ for more details
9898

9999
Args:
100100
token: An admin user&#39;s token, which starts with `xoxp-`
@@ -402,7 +402,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
402402
return resp</code></pre>
403403
</details>
404404
<div class="desc"><p>API client for Audit Logs API
405-
See <a href="https://api.slack.com/admins/audit-logs">https://api.slack.com/admins/audit-logs</a> for more details</p>
405+
See <a href="https://docs.slack.dev/admins/audit-logs-api/">https://docs.slack.dev/admins/audit-logs-api/</a> for more details</p>
406406
<h2 id="args">Args</h2>
407407
<dl>
408408
<dt><strong><code>token</code></strong></dt>

docs/reference/audit_logs/v1/async_client.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 class="title">Module <code>slack_sdk.audit_logs.v1.async_client</code></h1>
3737
</header>
3838
<section id="section-intro">
3939
<p>Audit Logs API is a set of APIs for monitoring what’s happening in your Enterprise Grid organization.</p>
40-
<p>Refer to <a href="https://slack.dev/python-slack-sdk/audit-logs/">https://slack.dev/python-slack-sdk/audit-logs/</a> for details.</p>
40+
<p>Refer to <a href="https://docs.slack.dev/tools/python-slack-sdk/audit-logs">https://docs.slack.dev/tools/python-slack-sdk/audit-logs</a> for details.</p>
4141
</section>
4242
<section>
4343
</section>
@@ -89,7 +89,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8989
retry_handlers: Optional[List[AsyncRetryHandler]] = None,
9090
):
9191
&#34;&#34;&#34;API client for Audit Logs API
92-
See https://api.slack.com/admins/audit-logs for more details
92+
See https://docs.slack.dev/admins/audit-logs-api/ for more details
9393

9494
Args:
9595
token: An admin user&#39;s token, which starts with `xoxp-`
@@ -391,7 +391,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
391391
return resp</code></pre>
392392
</details>
393393
<div class="desc"><p>API client for Audit Logs API
394-
See <a href="https://api.slack.com/admins/audit-logs">https://api.slack.com/admins/audit-logs</a> for more details</p>
394+
See <a href="https://docs.slack.dev/admins/audit-logs-api/">https://docs.slack.dev/admins/audit-logs-api/</a> for more details</p>
395395
<h2 id="args">Args</h2>
396396
<dl>
397397
<dt><strong><code>token</code></strong></dt>

docs/reference/audit_logs/v1/client.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 class="title">Module <code>slack_sdk.audit_logs.v1.client</code></h1>
3737
</header>
3838
<section id="section-intro">
3939
<p>Audit Logs API is a set of APIs for monitoring what’s happening in your Enterprise Grid organization.</p>
40-
<p>Refer to <a href="https://slack.dev/python-slack-sdk/audit-logs/">https://slack.dev/python-slack-sdk/audit-logs/</a> for details.</p>
40+
<p>Refer to <a href="https://docs.slack.dev/tools/python-slack-sdk/audit-logs">https://docs.slack.dev/tools/python-slack-sdk/audit-logs</a> for details.</p>
4141
</section>
4242
<section>
4343
</section>
@@ -83,7 +83,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
8383
retry_handlers: Optional[List[RetryHandler]] = None,
8484
):
8585
&#34;&#34;&#34;API client for Audit Logs API
86-
See https://api.slack.com/admins/audit-logs for more details
86+
See https://docs.slack.dev/admins/audit-logs-api/ for more details
8787

8888
Args:
8989
token: An admin user&#39;s token, which starts with `xoxp-`
@@ -391,7 +391,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
391391
return resp</code></pre>
392392
</details>
393393
<div class="desc"><p>API client for Audit Logs API
394-
See <a href="https://api.slack.com/admins/audit-logs">https://api.slack.com/admins/audit-logs</a> for more details</p>
394+
See <a href="https://docs.slack.dev/admins/audit-logs-api/">https://docs.slack.dev/admins/audit-logs-api/</a> for more details</p>
395395
<h2 id="args">Args</h2>
396396
<dl>
397397
<dt><strong><code>token</code></strong></dt>

docs/reference/audit_logs/v1/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 class="title">Module <code>slack_sdk.audit_logs.v1</code></h1>
3737
</header>
3838
<section id="section-intro">
3939
<p>Audit Logs API is a set of APIs for monitoring what’s happening in your Enterprise Grid organization.</p>
40-
<p>Refer to <a href="https://slack.dev/python-slack-sdk/audit-logs/">https://slack.dev/python-slack-sdk/audit-logs/</a> for details.</p>
40+
<p>Refer to <a href="https://docs.slack.dev/tools/python-slack-sdk/audit-logs">https://docs.slack.dev/tools/python-slack-sdk/audit-logs</a> for details.</p>
4141
</section>
4242
<section>
4343
<h2 class="section-title" id="header-submodules">Sub-modules</h2>

0 commit comments

Comments
 (0)