From 73e46fd0bba673533303eeb7858a4e1f0a016198 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Tue, 30 Sep 2025 21:32:58 -0700
Subject: [PATCH 01/18] feat(web-api): add a chat stream method to the web
client
---
docs/reference/index.html | 163 +++++++
docs/reference/web/async_chat_stream.html | 406 ++++++++++++++++++
docs/reference/web/async_client.html | 163 +++++++
docs/reference/web/chat_stream.html | 398 +++++++++++++++++
docs/reference/web/client.html | 163 +++++++
docs/reference/web/index.html | 173 ++++++++
docs/reference/web/legacy_client.html | 163 +++++++
slack_sdk/web/async_chat_stream.py | 166 +++++++
slack_sdk/web/async_client.py | 59 +++
slack_sdk/web/chat_stream.py | 162 +++++++
slack_sdk/web/client.py | 59 +++
slack_sdk/web/legacy_client.py | 59 +++
tests/slack_sdk/web/test_chat_stream.py | 142 ++++++
.../web_response_chat_stream_test.json | 4 +
14 files changed, 2280 insertions(+)
create mode 100644 docs/reference/web/async_chat_stream.html
create mode 100644 docs/reference/web/chat_stream.html
create mode 100644 slack_sdk/web/async_chat_stream.py
create mode 100644 slack_sdk/web/chat_stream.py
create mode 100644 tests/slack_sdk/web/test_chat_stream.py
create mode 100644 tests/slack_sdk_fixture/web_response_chat_stream_test.json
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 0245eb5ff..6cd8cbbeb 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -3030,6 +3030,64 @@
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
+ def chat_stream(
+ self,
+ *,
+ buffer_size: Optional[int] = 256,
+ channel: str,
+ thread_ts: str,
+ recipient_team_id: Optional[str] = None,
+ recipient_user_id: Optional[str] = None,
+ unfurl_links: Optional[bool] = None,
+ unfurl_media: Optional[bool] = None,
+ **kwargs,
+ ) -> ChatStream:
+ """Stream markdown text into a conversation.
+
+ This method provides an easy way to stream markdown text using the following endpoints:
+ - chat.startStream: Starts a new streaming conversation
+ - chat.appendStream: Appends text to an existing streaming conversation
+ - chat.stopStream: Stops a streaming conversation
+
+ Args:
+ buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ channel: Channel to stream to
+ thread_ts: Thread timestamp to stream to (required)
+ recipient_team_id: Team ID of the recipient (for Slack Connect)
+ recipient_user_id: User ID of the recipient (for Slack Connect)
+ unfurl_links: Whether to unfurl links
+ unfurl_media: Whether to unfurl media
+ **kwargs: Additional arguments passed to the underlying API calls
+
+ Returns:
+ ChatStreamer instance for managing the stream
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
+ """
+ return ChatStream(
+ self,
+ logger=self._logger,
+ channel=channel,
+ thread_ts=thread_ts,
+ recipient_team_id=recipient_team_id,
+ recipient_user_id=recipient_user_id,
+ unfurl_links=unfurl_links,
+ unfurl_media=unfurl_media,
+ buffer_size=buffer_size,
+ **kwargs,
+ )
+
def chat_stopStream(
self,
*,
@@ -10346,6 +10404,110 @@ Methods
+
+def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+
+
+
+
+Expand source code
+
+def chat_stream(
+ self,
+ *,
+ buffer_size: Optional[int] = 256,
+ channel: str,
+ thread_ts: str,
+ recipient_team_id: Optional[str] = None,
+ recipient_user_id: Optional[str] = None,
+ unfurl_links: Optional[bool] = None,
+ unfurl_media: Optional[bool] = None,
+ **kwargs,
+) -> ChatStream:
+ """Stream markdown text into a conversation.
+
+ This method provides an easy way to stream markdown text using the following endpoints:
+ - chat.startStream: Starts a new streaming conversation
+ - chat.appendStream: Appends text to an existing streaming conversation
+ - chat.stopStream: Stops a streaming conversation
+
+ Args:
+ buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ channel: Channel to stream to
+ thread_ts: Thread timestamp to stream to (required)
+ recipient_team_id: Team ID of the recipient (for Slack Connect)
+ recipient_user_id: User ID of the recipient (for Slack Connect)
+ unfurl_links: Whether to unfurl links
+ unfurl_media: Whether to unfurl media
+ **kwargs: Additional arguments passed to the underlying API calls
+
+ Returns:
+ ChatStreamer instance for managing the stream
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
+ """
+ return ChatStream(
+ self,
+ logger=self._logger,
+ channel=channel,
+ thread_ts=thread_ts,
+ recipient_team_id=recipient_team_id,
+ recipient_user_id=recipient_user_id,
+ unfurl_links=unfurl_links,
+ unfurl_media=unfurl_media,
+ buffer_size=buffer_size,
+ **kwargs,
+ )
+
+Stream markdown text into a conversation.
+
This method provides an easy way to stream markdown text using the following endpoints:
+- chat.startStream: Starts a new streaming conversation
+- chat.appendStream: Appends text to an existing streaming conversation
+- chat.stopStream: Stops a streaming conversation
+
Args
+
+buffer_size
+- Size of the internal buffer before automatically flushing (default: 256)
+channel
+- Channel to stream to
+thread_ts
+- Thread timestamp to stream to (required)
+recipient_team_id
+- Team ID of the recipient (for Slack Connect)
+recipient_user_id
+- User ID of the recipient (for Slack Connect)
+unfurl_links
+- Whether to unfurl links
+unfurl_media
+- Whether to unfurl media
+**kwargs
+- Additional arguments passed to the underlying API calls
+
+
Returns
+
ChatStreamer instance for managing the stream
+
Example
+
streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+)
+streamer.append(markdown_text="**hello wo")
+streamer.append(markdown_text="rld!**")
+streamer.stop()
+
+
def chat_unfurl(self,
*,
channel: str | None = None,
ts: str | None = None,
source: str | None = None,
unfurl_id: str | None = None,
unfurls: Dict[str, Dict] | None = None,
user_auth_blocks: str | Sequence[Dict | Block] | None = None,
user_auth_message: str | None = None,
user_auth_required: bool | None = None,
user_auth_url: str | None = None,
**kwargs) ‑> SlackResponse
@@ -15323,6 +15485,7 @@
-def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
@@ -10415,7 +10415,7 @@ Methods
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
diff --git a/docs/reference/web/async_chat_stream.html b/docs/reference/web/async_chat_stream.html
index 8c7900814..cf5db2979 100644
--- a/docs/reference/web/async_chat_stream.html
+++ b/docs/reference/web/async_chat_stream.html
@@ -102,6 +102,7 @@
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
+ self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
async def append(
@@ -124,6 +125,8 @@
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
self._buffer += markdown_text
if len(self._buffer) >= self._buffer_size:
return await self._flush_buffer(**kwargs)
@@ -162,26 +165,25 @@
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
if markdown_text:
self._buffer += markdown_text
if not self._stream_ts:
response = await self._client.chat_startStream(
**self._stream_args,
- **kwargs,
+ token=self._token,
)
if not response.get("ts"):
raise e.SlackRequestError("Failed to stop stream: stream not started")
self._stream_ts = str(response["ts"])
self._state = "in_progress"
-
- print(f"_stream_args: {self._stream_args}\n") # todo
- print(f"_buffer: {self._buffer}\n")
-
response = await self._client.chat_stopStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
blocks=blocks,
- markdown_text=self._buffer + (markdown_text if markdown_text is not None else ""),
+ markdown_text=self._buffer,
metadata=metadata,
**kwargs,
)
@@ -193,17 +195,19 @@
if not self._stream_ts:
response = await self._client.chat_startStream(
**self._stream_args,
- markdown_text=self._buffer,
+ token=self._token,
**kwargs,
+ markdown_text=self._buffer,
)
self._stream_ts = response.get("ts")
self._state = "in_progress"
else:
response = await self._client.chat_appendStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
- markdown_text=self._buffer,
**kwargs,
+ markdown_text=self._buffer,
)
self._buffer = ""
@@ -262,6 +266,8 @@ Methods
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
self._buffer += markdown_text
if len(self._buffer) >= self._buffer_size:
return await self._flush_buffer(**kwargs)
@@ -324,26 +330,25 @@ Raises
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
if markdown_text:
self._buffer += markdown_text
if not self._stream_ts:
response = await self._client.chat_startStream(
**self._stream_args,
- **kwargs,
+ token=self._token,
)
if not response.get("ts"):
raise e.SlackRequestError("Failed to stop stream: stream not started")
self._stream_ts = str(response["ts"])
self._state = "in_progress"
-
- print(f"_stream_args: {self._stream_args}\n") # todo
- print(f"_buffer: {self._buffer}\n")
-
response = await self._client.chat_stopStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
blocks=blocks,
- markdown_text=self._buffer + (markdown_text if markdown_text is not None else ""),
+ markdown_text=self._buffer,
metadata=metadata,
**kwargs,
)
diff --git a/docs/reference/web/async_client.html b/docs/reference/web/async_client.html
index 3ee659eb4..66cf63ad4 100644
--- a/docs/reference/web/async_client.html
+++ b/docs/reference/web/async_client.html
@@ -2929,7 +2929,7 @@
async def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
@@ -2937,7 +2937,7 @@
unfurl_links: Optional[bool] = None,
unfurl_media: Optional[bool] = None,
**kwargs,
- ) -> ChatStream:
+ ) -> AsyncChatStream:
"""Stream markdown text into a conversation.
This method provides an easy way to stream markdown text using the following endpoints:
@@ -2960,18 +2960,18 @@
Example:
```python
- streamer = client.chat_stream(
+ streamer = await client.chat_stream(
channel="C0123456789",
thread_ts="1700000001.123456",
recipient_team_id="T0123456789",
recipient_user_id="U0123456789",
)
- streamer.append(markdown_text="**hello wo")
- streamer.append(markdown_text="rld!**")
- streamer.stop()
+ await streamer.append(markdown_text="**hello wo")
+ await streamer.append(markdown_text="rld!**")
+ await streamer.stop()
```
"""
- return ChatStream(
+ return AsyncChatStream(
self,
logger=self._logger,
channel=channel,
@@ -10301,7 +10301,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-async def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+async def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> AsyncChatStream
@@ -10311,7 +10311,7 @@ Methods
async def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
@@ -10319,7 +10319,7 @@ Methods
unfurl_links: Optional[bool] = None,
unfurl_media: Optional[bool] = None,
**kwargs,
-) -> ChatStream:
+) -> AsyncChatStream:
"""Stream markdown text into a conversation.
This method provides an easy way to stream markdown text using the following endpoints:
@@ -10342,18 +10342,18 @@ Methods
Example:
```python
- streamer = client.chat_stream(
+ streamer = await client.chat_stream(
channel="C0123456789",
thread_ts="1700000001.123456",
recipient_team_id="T0123456789",
recipient_user_id="U0123456789",
)
- streamer.append(markdown_text="**hello wo")
- streamer.append(markdown_text="rld!**")
- streamer.stop()
+ await streamer.append(markdown_text="**hello wo")
+ await streamer.append(markdown_text="rld!**")
+ await streamer.stop()
```
"""
- return ChatStream(
+ return AsyncChatStream(
self,
logger=self._logger,
channel=channel,
@@ -10393,15 +10393,15 @@ Args
Returns
ChatStreamer instance for managing the stream
Example
-streamer = client.chat_stream(
+streamer = await client.chat_stream(
channel="C0123456789",
thread_ts="1700000001.123456",
recipient_team_id="T0123456789",
recipient_user_id="U0123456789",
)
-streamer.append(markdown_text="**hello wo")
-streamer.append(markdown_text="rld!**")
-streamer.stop()
+await streamer.append(markdown_text="**hello wo")
+await streamer.append(markdown_text="rld!**")
+await streamer.stop()
diff --git a/docs/reference/web/chat_stream.html b/docs/reference/web/chat_stream.html
index c23ae4343..434a5794b 100644
--- a/docs/reference/web/chat_stream.html
+++ b/docs/reference/web/chat_stream.html
@@ -102,6 +102,7 @@
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
+ self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
def append(
@@ -124,6 +125,8 @@
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
self._buffer += markdown_text
if len(self._buffer) >= self._buffer_size:
return self._flush_buffer(**kwargs)
@@ -162,18 +165,21 @@
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
if markdown_text:
self._buffer += markdown_text
if not self._stream_ts:
response = self._client.chat_startStream(
**self._stream_args,
- **kwargs,
+ token=self._token,
)
if not response.get("ts"):
raise e.SlackRequestError("Failed to stop stream: stream not started")
self._stream_ts = str(response["ts"])
self._state = "in_progress"
response = self._client.chat_stopStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
blocks=blocks,
@@ -189,17 +195,19 @@
if not self._stream_ts:
response = self._client.chat_startStream(
**self._stream_args,
- markdown_text=self._buffer,
+ token=self._token,
**kwargs,
+ markdown_text=self._buffer,
)
self._stream_ts = response.get("ts")
self._state = "in_progress"
else:
response = self._client.chat_appendStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
- markdown_text=self._buffer,
**kwargs,
+ markdown_text=self._buffer,
)
self._buffer = ""
@@ -258,6 +266,8 @@ Methods
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
self._buffer += markdown_text
if len(self._buffer) >= self._buffer_size:
return self._flush_buffer(**kwargs)
@@ -320,18 +330,21 @@ Raises
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
+ if kwargs.get("token"):
+ self._token = kwargs.pop("token")
if markdown_text:
self._buffer += markdown_text
if not self._stream_ts:
response = self._client.chat_startStream(
**self._stream_args,
- **kwargs,
+ token=self._token,
)
if not response.get("ts"):
raise e.SlackRequestError("Failed to stop stream: stream not started")
self._stream_ts = str(response["ts"])
self._state = "in_progress"
response = self._client.chat_stopStream(
+ token=self._token,
channel=self._stream_args["channel"],
ts=self._stream_ts,
blocks=blocks,
diff --git a/docs/reference/web/client.html b/docs/reference/web/client.html
index 0ad9ca23b..b28f6e956 100644
--- a/docs/reference/web/client.html
+++ b/docs/reference/web/client.html
@@ -2929,7 +2929,7 @@
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
@@ -10301,7 +10301,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
@@ -10311,7 +10311,7 @@ Methods
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
diff --git a/docs/reference/web/index.html b/docs/reference/web/index.html
index 38087d56f..6fccde48a 100644
--- a/docs/reference/web/index.html
+++ b/docs/reference/web/index.html
@@ -3298,7 +3298,7 @@ Raises
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
@@ -10670,7 +10670,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
@@ -10680,7 +10680,7 @@ Methods
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
diff --git a/docs/reference/web/legacy_client.html b/docs/reference/web/legacy_client.html
index dff0bb98a..79583d84d 100644
--- a/docs/reference/web/legacy_client.html
+++ b/docs/reference/web/legacy_client.html
@@ -2928,7 +2928,7 @@
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
@@ -10300,7 +10300,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int | None = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
@@ -10310,7 +10310,7 @@ Methods
def chat_stream(
self,
*,
- buffer_size: Optional[int] = 256,
+ buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: Optional[str] = None,
From 03566bd0c2cf1fe9131e42bdfd78a709a088ef65 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 14:33:23 -0700
Subject: [PATCH 09/18] feat: remove legacy implementation
---
docs/reference/web/legacy_client.html | 163 --------------------------
scripts/codegen.py | 2 +
slack_sdk/web/legacy_client.py | 60 +---------
3 files changed, 3 insertions(+), 222 deletions(-)
diff --git a/docs/reference/web/legacy_client.html b/docs/reference/web/legacy_client.html
index 79583d84d..1d4ebbed8 100644
--- a/docs/reference/web/legacy_client.html
+++ b/docs/reference/web/legacy_client.html
@@ -2925,64 +2925,6 @@
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
- def chat_stream(
- self,
- *,
- buffer_size: int = 256,
- channel: str,
- thread_ts: str,
- recipient_team_id: Optional[str] = None,
- recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
- **kwargs,
- ) -> ChatStream:
- """Stream markdown text into a conversation.
-
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
-
- Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
-
- Returns:
- ChatStreamer instance for managing the stream
-
- Example:
- ```python
- streamer = client.chat_stream(
- channel="C0123456789",
- thread_ts="1700000001.123456",
- recipient_team_id="T0123456789",
- recipient_user_id="U0123456789",
- )
- streamer.append(markdown_text="**hello wo")
- streamer.append(markdown_text="rld!**")
- streamer.stop()
- ```
- """
- return ChatStream(
- self,
- logger=self._logger,
- channel=channel,
- thread_ts=thread_ts,
- recipient_team_id=recipient_team_id,
- recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
- buffer_size=buffer_size,
- **kwargs,
- )
-
def chat_stopStream(
self,
*,
@@ -10299,110 +10241,6 @@ Methods
-
-def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
-
-
-
-
-Expand source code
-
-def chat_stream(
- self,
- *,
- buffer_size: int = 256,
- channel: str,
- thread_ts: str,
- recipient_team_id: Optional[str] = None,
- recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
- **kwargs,
-) -> ChatStream:
- """Stream markdown text into a conversation.
-
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
-
- Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
-
- Returns:
- ChatStreamer instance for managing the stream
-
- Example:
- ```python
- streamer = client.chat_stream(
- channel="C0123456789",
- thread_ts="1700000001.123456",
- recipient_team_id="T0123456789",
- recipient_user_id="U0123456789",
- )
- streamer.append(markdown_text="**hello wo")
- streamer.append(markdown_text="rld!**")
- streamer.stop()
- ```
- """
- return ChatStream(
- self,
- logger=self._logger,
- channel=channel,
- thread_ts=thread_ts,
- recipient_team_id=recipient_team_id,
- recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
- buffer_size=buffer_size,
- **kwargs,
- )
-
-Stream markdown text into a conversation.
-
This method provides an easy way to stream markdown text using the following endpoints:
-- chat.startStream: Starts a new streaming conversation
-- chat.appendStream: Appends text to an existing streaming conversation
-- chat.stopStream: Stops a streaming conversation
-
Args
-
-buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
-channel
-- Channel to stream to
-thread_ts
-- Thread timestamp to stream to (required)
-recipient_team_id
-- Team ID of the recipient (for Slack Connect)
-recipient_user_id
-- User ID of the recipient (for Slack Connect)
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
-**kwargs
-- Additional arguments passed to the underlying API calls
-
-
Returns
-
ChatStreamer instance for managing the stream
-
Example
-
streamer = client.chat_stream(
- channel="C0123456789",
- thread_ts="1700000001.123456",
- recipient_team_id="T0123456789",
- recipient_user_id="U0123456789",
-)
-streamer.append(markdown_text="**hello wo")
-streamer.append(markdown_text="rld!**")
-streamer.stop()
-
-
def chat_unfurl(self,
*,
channel: str | None = None,
ts: str | None = None,
source: str | None = None,
unfurl_id: str | None = None,
unfurls: Dict[str, Dict] | None = None,
user_auth_blocks: str | Sequence[Dict | Block] | None = None,
user_auth_message: str | None = None,
user_auth_required: bool | None = None,
user_auth_url: str | None = None,
**kwargs) ‑> _asyncio.Future | LegacySlackResponse
@@ -14918,7 +14756,6 @@ chat_scheduledMessages_list
chat_startStream
chat_stopStream
-chat_stream
chat_unfurl
chat_update
conversations_acceptSharedInvite
diff --git a/scripts/codegen.py b/scripts/codegen.py
index 9bff4e474..b23088b5a 100644
--- a/scripts/codegen.py
+++ b/scripts/codegen.py
@@ -119,6 +119,8 @@
legacy_source,
)
legacy_source = re.sub(r"= WebClient\(", "= LegacyWebClient(", legacy_source)
+ legacy_source = re.sub(r"from slack_sdk.web.chat_stream import ChatStream", "", legacy_source)
+ legacy_source = re.sub(r"(?s)def chat_stream.*?(?=def\s+chat_stopStream\()", "", legacy_source)
with open(f"{args.path}/slack_sdk/web/legacy_client.py", "w") as output:
output.write(legacy_source)
diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py
index a8aac3602..1eeee1f40 100644
--- a/slack_sdk/web/legacy_client.py
+++ b/slack_sdk/web/legacy_client.py
@@ -20,7 +20,7 @@
import slack_sdk.errors as e
from slack_sdk.models.views import View
-from slack_sdk.web.chat_stream import ChatStream
+
from ..models.attachments import Attachment
from ..models.blocks import Block
@@ -2907,64 +2907,6 @@ def chat_startStream(
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
- def chat_stream(
- self,
- *,
- buffer_size: int = 256,
- channel: str,
- thread_ts: str,
- recipient_team_id: Optional[str] = None,
- recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
- **kwargs,
- ) -> ChatStream:
- """Stream markdown text into a conversation.
-
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
-
- Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
-
- Returns:
- ChatStreamer instance for managing the stream
-
- Example:
- ```python
- streamer = client.chat_stream(
- channel="C0123456789",
- thread_ts="1700000001.123456",
- recipient_team_id="T0123456789",
- recipient_user_id="U0123456789",
- )
- streamer.append(markdown_text="**hello wo")
- streamer.append(markdown_text="rld!**")
- streamer.stop()
- ```
- """
- return ChatStream(
- self,
- logger=self._logger,
- channel=channel,
- thread_ts=thread_ts,
- recipient_team_id=recipient_team_id,
- recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
- buffer_size=buffer_size,
- **kwargs,
- )
-
def chat_stopStream(
self,
*,
From 187c71924338ae3349259bbfd7c53d6da727c88a Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 16:22:31 -0700
Subject: [PATCH 10/18] fix: improve docs to match arguments with better
testing
---
docs/reference/index.html | 93 ++++----
docs/reference/web/async_chat_stream.html | 205 ++++++++++++------
docs/reference/web/async_client.html | 93 ++++----
docs/reference/web/chat_stream.html | 205 ++++++++++++------
docs/reference/web/client.html | 93 ++++----
docs/reference/web/index.html | 93 ++++----
slack_sdk/web/async_chat_stream.py | 78 ++++---
slack_sdk/web/async_client.py | 31 ++-
slack_sdk/web/chat_stream.py | 78 ++++---
slack_sdk/web/client.py | 31 ++-
tests/slack_sdk/web/test_chat_stream.py | 29 ++-
.../web/test_async_chat_stream.py | 31 ++-
...response_chat_stream_test_missing_ts.json} | 0
.../web_response_chat_stream_test_token1.json | 3 +
.../web_response_chat_stream_test_token2.json | 3 +
15 files changed, 642 insertions(+), 424 deletions(-)
rename tests/slack_sdk_fixture/{web_response_chat_stream_test_token.json => web_response_chat_stream_test_missing_ts.json} (100%)
create mode 100644 tests/slack_sdk_fixture/web_response_chat_stream_test_token1.json
create mode 100644 tests/slack_sdk_fixture/web_response_chat_stream_test_token2.json
diff --git a/docs/reference/index.html b/docs/reference/index.html
index ce7b50c45..76fdfb093 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -3038,29 +3038,28 @@
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -3082,8 +3081,6 @@
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
@@ -10405,7 +10402,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs) ‑> ChatStream
@@ -10420,29 +10417,28 @@ Methods
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -10464,38 +10460,35 @@ Methods
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
Stream markdown text into a conversation.
-
This method provides an easy way to stream markdown text using the following endpoints:
-- chat.startStream: Starts a new streaming conversation
-- chat.appendStream: Appends text to an existing streaming conversation
-- chat.stopStream: Stops a streaming conversation
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
The following methods are used:
+
+- chat.startStream: Starts a new streaming conversation. Reference.
+- chat.appendStream: Appends text to an existing streaming conversation. Reference.
+- chat.stopStream: Stops a streaming conversation. Reference.
+
Args
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
channel
-- Channel to stream to
+- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Thread timestamp to stream to (required)
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient (for Slack Connect)
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient (for Slack Connect)
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
ChatStreamer instance for managing the stream
+
ChatStream instance for managing the stream
Example
streamer = client.chat_stream(
channel="C0123456789",
diff --git a/docs/reference/web/async_chat_stream.html b/docs/reference/web/async_chat_stream.html
index cf5db2979..8e9d0ef91 100644
--- a/docs/reference/web/async_chat_stream.html
+++ b/docs/reference/web/async_chat_stream.html
@@ -48,7 +48,7 @@
class AsyncChatStream
-(client: AsyncWebClient,
*,
channel: str,
logger: logging.Logger,
thread_ts: str,
buffer_size: int,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs)
+(client: AsyncWebClient,
*,
channel: str,
logger: logging.Logger,
thread_ts: str,
buffer_size: int,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs)
-
@@ -58,8 +58,7 @@
class AsyncChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream,
- and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
"""
def __init__(
@@ -72,37 +71,35 @@
buffer_size: int,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
):
"""Initialize a new ChatStream instance.
+ The __init__ method creates a unique ChatStream instance that keeps track of one chat stream.
+
Args:
- client: The WebClient instance to use for API calls
- channel: Channel ID to stream to
- thread_ts: Thread timestamp to stream to
- recipient_team_id: Team ID of the recipient
- recipient_user_id: User ID of the recipient
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ client: The WebClient instance to use for API calls.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ logger: A logging channel for outputs.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ **kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
self._logger = logger
+ self._token: Optional[str] = kwargs.pop("token", None)
self._stream_args = {
"channel": channel,
"thread_ts": thread_ts,
"recipient_team_id": recipient_team_id,
"recipient_user_id": recipient_user_id,
- "unfurl_links": unfurl_links,
- "unfurl_media": unfurl_media,
**kwargs,
}
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
- self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
async def append(
@@ -111,17 +108,32 @@
markdown_text: str,
**kwargs,
) -> Optional[AsyncSlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse if the buffer was flushed, None if buffering
+ AsyncSlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -152,16 +164,29 @@
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse from the chat.stopStream API call
+ AsyncSlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -209,32 +234,31 @@
**kwargs,
markdown_text=self._buffer,
)
-
self._buffer = ""
return response
A helper class for streaming markdown text into a conversation using the chat streaming APIs.
-
This class provides a convenient interface for the chat.startStream, chat.appendStream,
-and chat.stopStream API methods, with automatic buffering and state management.
+
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
Initialize a new ChatStream instance.
+
The init method creates a unique ChatStream instance that keeps track of one chat stream.
Args
client
-- The WebClient instance to use for API calls
+- The WebClient instance to use for API calls.
channel
-- Channel ID to stream to
+- An encoded ID that represents a channel, private group, or DM.
+logger
+- A logging channel for outputs.
thread_ts
-- Thread timestamp to stream to
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+**kwargs
+- Additional arguments passed to the underlying API calls.
Methods
@@ -252,17 +276,32 @@ Methods
markdown_text: str,
**kwargs,
) -> Optional[AsyncSlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse if the buffer was flushed, None if buffering
+ AsyncSlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -282,21 +321,33 @@ Methods
self._logger.debug(f"ChatStream appended to buffer: {json.dumps(details)}")
return None
-
Append markdown text to the stream.
+
Append to the stream.
+
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args
markdown_text
-- The markdown text to append
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
AsyncSlackResponse if the buffer was flushed, None if buffering
+
AsyncSlackResponse if the buffer was flushed, None if buffering.
Raises
SlackRequestError
-- If the stream is already completed
-
+
If the stream is already completed.
+
+
Example
+
streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+)
+streamer.append(markdown_text="**hello wo")
+streamer.append(markdown_text="rld!**")
+streamer.stop()
+
async def stop(self,
*,
markdown_text: str | None = None,
blocks: str | Sequence[Dict | Block] | None = None,
metadata: Dict | Metadata | None = None,
**kwargs) ‑> AsyncSlackResponse
@@ -317,16 +368,29 @@ Raises
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse from the chat.stopStream API call
+ AsyncSlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -358,22 +422,33 @@ Raises
Stop the stream and finalize the message.
Args
-markdown_text
-- Additional markdown text to append before stopping
blocks
-- Message blocks to add to the final message
+- A list of blocks that will be rendered at the bottom of the finalized message.
+markdown_text
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
metadata
-- Message metadata to add to the final message
+- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
AsyncSlackResponse from the chat.stopStream API call
+
AsyncSlackResponse from the chat.stopStream API call.
Raises
SlackRequestError
-- If the stream is already completed
-
+If the stream is already completed.
+
+Example
+streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+)
+streamer.append(markdown_text="**hello wo")
+streamer.append(markdown_text="rld!**")
+streamer.stop()
+
diff --git a/docs/reference/web/async_client.html b/docs/reference/web/async_client.html
index 66cf63ad4..24943a71f 100644
--- a/docs/reference/web/async_client.html
+++ b/docs/reference/web/async_client.html
@@ -2934,29 +2934,28 @@
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -2978,8 +2977,6 @@
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
@@ -10301,7 +10298,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-async def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> AsyncChatStream
+async def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs) ‑> AsyncChatStream
@@ -10316,29 +10313,28 @@ Methods
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -10360,38 +10356,35 @@ Methods
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
Stream markdown text into a conversation.
-
This method provides an easy way to stream markdown text using the following endpoints:
-- chat.startStream: Starts a new streaming conversation
-- chat.appendStream: Appends text to an existing streaming conversation
-- chat.stopStream: Stops a streaming conversation
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
The following methods are used:
+
+- chat.startStream: Starts a new streaming conversation. Reference.
+- chat.appendStream: Appends text to an existing streaming conversation. Reference.
+- chat.stopStream: Stops a streaming conversation. Reference.
+
Args
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
channel
-- Channel to stream to
+- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Thread timestamp to stream to (required)
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient (for Slack Connect)
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient (for Slack Connect)
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
ChatStreamer instance for managing the stream
+
ChatStream instance for managing the stream
Example
streamer = await client.chat_stream(
channel="C0123456789",
diff --git a/docs/reference/web/chat_stream.html b/docs/reference/web/chat_stream.html
index 434a5794b..2f4dea425 100644
--- a/docs/reference/web/chat_stream.html
+++ b/docs/reference/web/chat_stream.html
@@ -48,7 +48,7 @@
class ChatStream
-(client: WebClient,
*,
channel: str,
logger: logging.Logger,
thread_ts: str,
buffer_size: int,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs)
+(client: WebClient,
*,
channel: str,
logger: logging.Logger,
thread_ts: str,
buffer_size: int,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs)
-
@@ -58,8 +58,7 @@
class ChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream,
- and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
"""
def __init__(
@@ -72,37 +71,35 @@
buffer_size: int,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
):
"""Initialize a new ChatStream instance.
+ The __init__ method creates a unique ChatStream instance that keeps track of one chat stream.
+
Args:
- client: The WebClient instance to use for API calls
- channel: Channel ID to stream to
- thread_ts: Thread timestamp to stream to
- recipient_team_id: Team ID of the recipient
- recipient_user_id: User ID of the recipient
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ client: The WebClient instance to use for API calls.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ logger: A logging channel for outputs.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ **kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
self._logger = logger
+ self._token: Optional[str] = kwargs.pop("token", None)
self._stream_args = {
"channel": channel,
"thread_ts": thread_ts,
"recipient_team_id": recipient_team_id,
"recipient_user_id": recipient_user_id,
- "unfurl_links": unfurl_links,
- "unfurl_media": unfurl_media,
**kwargs,
}
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
- self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
def append(
@@ -111,17 +108,32 @@
markdown_text: str,
**kwargs,
) -> Optional[SlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse if the buffer was flushed, None if buffering
+ SlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -152,16 +164,29 @@
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse from the chat.stopStream API call
+ SlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -209,32 +234,31 @@
**kwargs,
markdown_text=self._buffer,
)
-
self._buffer = ""
return response
A helper class for streaming markdown text into a conversation using the chat streaming APIs.
-
This class provides a convenient interface for the chat.startStream, chat.appendStream,
-and chat.stopStream API methods, with automatic buffering and state management.
+
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
Initialize a new ChatStream instance.
+
The init method creates a unique ChatStream instance that keeps track of one chat stream.
Args
client
-- The WebClient instance to use for API calls
+- The WebClient instance to use for API calls.
channel
-- Channel ID to stream to
+- An encoded ID that represents a channel, private group, or DM.
+logger
+- A logging channel for outputs.
thread_ts
-- Thread timestamp to stream to
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+**kwargs
+- Additional arguments passed to the underlying API calls.
Methods
@@ -252,17 +276,32 @@ Methods
markdown_text: str,
**kwargs,
) -> Optional[SlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse if the buffer was flushed, None if buffering
+ SlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -282,21 +321,33 @@ Methods
self._logger.debug(f"ChatStream appended to buffer: {json.dumps(details)}")
return None
-
Append markdown text to the stream.
+
Append to the stream.
+
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args
markdown_text
-- The markdown text to append
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
SlackResponse if the buffer was flushed, None if buffering
+
SlackResponse if the buffer was flushed, None if buffering.
Raises
SlackRequestError
-- If the stream is already completed
-
+
If the stream is already completed.
+
+
Example
+
streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+)
+streamer.append(markdown_text="**hello wo")
+streamer.append(markdown_text="rld!**")
+streamer.stop()
+
def stop(self,
*,
markdown_text: str | None = None,
blocks: str | Sequence[Dict | Block] | None = None,
metadata: Dict | Metadata | None = None,
**kwargs) ‑> SlackResponse
@@ -317,16 +368,29 @@ Raises
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse from the chat.stopStream API call
+ SlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -358,22 +422,33 @@ Raises
Stop the stream and finalize the message.
Args
-markdown_text
-- Additional markdown text to append before stopping
blocks
-- Message blocks to add to the final message
+- A list of blocks that will be rendered at the bottom of the finalized message.
+markdown_text
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
metadata
-- Message metadata to add to the final message
+- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
SlackResponse from the chat.stopStream API call
+
SlackResponse from the chat.stopStream API call.
Raises
SlackRequestError
-- If the stream is already completed
-
+If the stream is already completed.
+
+Example
+streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+)
+streamer.append(markdown_text="**hello wo")
+streamer.append(markdown_text="rld!**")
+streamer.stop()
+
diff --git a/docs/reference/web/client.html b/docs/reference/web/client.html
index b28f6e956..886ada4ad 100644
--- a/docs/reference/web/client.html
+++ b/docs/reference/web/client.html
@@ -2934,29 +2934,28 @@
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -2978,8 +2977,6 @@
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
@@ -10301,7 +10298,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs) ‑> ChatStream
@@ -10316,29 +10313,28 @@ Methods
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -10360,38 +10356,35 @@ Methods
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
Stream markdown text into a conversation.
-
This method provides an easy way to stream markdown text using the following endpoints:
-- chat.startStream: Starts a new streaming conversation
-- chat.appendStream: Appends text to an existing streaming conversation
-- chat.stopStream: Stops a streaming conversation
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
The following methods are used:
+
+- chat.startStream: Starts a new streaming conversation. Reference.
+- chat.appendStream: Appends text to an existing streaming conversation. Reference.
+- chat.stopStream: Stops a streaming conversation. Reference.
+
Args
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
channel
-- Channel to stream to
+- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Thread timestamp to stream to (required)
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient (for Slack Connect)
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient (for Slack Connect)
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
ChatStreamer instance for managing the stream
+
ChatStream instance for managing the stream
Example
streamer = client.chat_stream(
channel="C0123456789",
diff --git a/docs/reference/web/index.html b/docs/reference/web/index.html
index 6fccde48a..3a8f81cc6 100644
--- a/docs/reference/web/index.html
+++ b/docs/reference/web/index.html
@@ -3303,29 +3303,28 @@ Raises
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -3347,8 +3346,6 @@ Raises
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
@@ -10670,7 +10667,7 @@ Methods
https://api.slack.com/methods/chat.stopStream
-def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
unfurl_links: bool | None = None,
unfurl_media: bool | None = None,
**kwargs) ‑> ChatStream
+def chat_stream(self,
*,
buffer_size: int = 256,
channel: str,
thread_ts: str,
recipient_team_id: str | None = None,
recipient_user_id: str | None = None,
**kwargs) ‑> ChatStream
@@ -10685,29 +10682,28 @@ Methods
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -10729,38 +10725,35 @@ Methods
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
Stream markdown text into a conversation.
-
This method provides an easy way to stream markdown text using the following endpoints:
-- chat.startStream: Starts a new streaming conversation
-- chat.appendStream: Appends text to an existing streaming conversation
-- chat.stopStream: Stops a streaming conversation
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
The following methods are used:
+
+- chat.startStream: Starts a new streaming conversation. Reference.
+- chat.appendStream: Appends text to an existing streaming conversation. Reference.
+- chat.stopStream: Stops a streaming conversation. Reference.
+
Args
buffer_size
-- Size of the internal buffer before automatically flushing (default: 256)
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
channel
-- Channel to stream to
+- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Thread timestamp to stream to (required)
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
recipient_team_id
-- Team ID of the recipient (for Slack Connect)
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
recipient_user_id
-- User ID of the recipient (for Slack Connect)
-unfurl_links
-- Whether to unfurl links
-unfurl_media
-- Whether to unfurl media
+- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
-- Additional arguments passed to the underlying API calls
+- Additional arguments passed to the underlying API calls.
Returns
-
ChatStreamer instance for managing the stream
+
ChatStream instance for managing the stream
Example
streamer = client.chat_stream(
channel="C0123456789",
diff --git a/slack_sdk/web/async_chat_stream.py b/slack_sdk/web/async_chat_stream.py
index ccf7b1969..a94c8d00b 100644
--- a/slack_sdk/web/async_chat_stream.py
+++ b/slack_sdk/web/async_chat_stream.py
@@ -24,8 +24,7 @@
class AsyncChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream,
- and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
"""
def __init__(
@@ -38,37 +37,35 @@ def __init__(
buffer_size: int,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
):
"""Initialize a new ChatStream instance.
+ The __init__ method creates a unique ChatStream instance that keeps track of one chat stream.
+
Args:
- client: The WebClient instance to use for API calls
- channel: Channel ID to stream to
- thread_ts: Thread timestamp to stream to
- recipient_team_id: Team ID of the recipient
- recipient_user_id: User ID of the recipient
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ client: The WebClient instance to use for API calls.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ logger: A logging channel for outputs.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ **kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
self._logger = logger
+ self._token: Optional[str] = kwargs.pop("token", None)
self._stream_args = {
"channel": channel,
"thread_ts": thread_ts,
"recipient_team_id": recipient_team_id,
"recipient_user_id": recipient_user_id,
- "unfurl_links": unfurl_links,
- "unfurl_media": unfurl_media,
**kwargs,
}
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
- self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
async def append(
@@ -77,17 +74,32 @@ async def append(
markdown_text: str,
**kwargs,
) -> Optional[AsyncSlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse if the buffer was flushed, None if buffering
+ AsyncSlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -118,16 +130,29 @@ async def stop(
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- AsyncSlackResponse from the chat.stopStream API call
+ AsyncSlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -175,6 +200,5 @@ async def _flush_buffer(self, **kwargs) -> AsyncSlackResponse:
**kwargs,
markdown_text=self._buffer,
)
-
self._buffer = ""
return response
diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py
index bb776efb7..74d385129 100644
--- a/slack_sdk/web/async_client.py
+++ b/slack_sdk/web/async_client.py
@@ -2913,29 +2913,28 @@ async def chat_stream(
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -2957,8 +2956,6 @@ async def chat_stream(
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
diff --git a/slack_sdk/web/chat_stream.py b/slack_sdk/web/chat_stream.py
index 6923fba98..47d77b450 100644
--- a/slack_sdk/web/chat_stream.py
+++ b/slack_sdk/web/chat_stream.py
@@ -14,8 +14,7 @@
class ChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream,
- and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
"""
def __init__(
@@ -28,37 +27,35 @@ def __init__(
buffer_size: int,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
):
"""Initialize a new ChatStream instance.
+ The __init__ method creates a unique ChatStream instance that keeps track of one chat stream.
+
Args:
- client: The WebClient instance to use for API calls
- channel: Channel ID to stream to
- thread_ts: Thread timestamp to stream to
- recipient_team_id: Team ID of the recipient
- recipient_user_id: User ID of the recipient
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
+ client: The WebClient instance to use for API calls.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ logger: A logging channel for outputs.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ **kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
self._logger = logger
+ self._token: Optional[str] = kwargs.pop("token", None)
self._stream_args = {
"channel": channel,
"thread_ts": thread_ts,
"recipient_team_id": recipient_team_id,
"recipient_user_id": recipient_user_id,
- "unfurl_links": unfurl_links,
- "unfurl_media": unfurl_media,
**kwargs,
}
self._buffer = ""
self._state = "starting"
self._stream_ts: Optional[str] = None
- self._token: Optional[str] = kwargs.get("token")
self._buffer_size = buffer_size
def append(
@@ -67,17 +64,32 @@ def append(
markdown_text: str,
**kwargs,
) -> Optional[SlackResponse]:
- """Append markdown text to the stream.
+ """Append to the stream.
+
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
Args:
- markdown_text: The markdown text to append
- **kwargs: Additional arguments passed to the underlying API calls
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse if the buffer was flushed, None if buffering
+ SlackResponse if the buffer was flushed, None if buffering.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot append to stream: stream state is {self._state}")
@@ -108,16 +120,29 @@ def stop(
"""Stop the stream and finalize the message.
Args:
- markdown_text: Additional markdown text to append before stopping
- blocks: Message blocks to add to the final message
- metadata: Message metadata to add to the final message
- **kwargs: Additional arguments passed to the underlying API calls
+ blocks: A list of blocks that will be rendered at the bottom of the finalized message.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- SlackResponse from the chat.stopStream API call
+ SlackResponse from the chat.stopStream API call.
Raises:
- SlackRequestError: If the stream is already completed
+ SlackRequestError: If the stream is already completed.
+
+ Example:
+ ```python
+ streamer = client.chat_stream(
+ channel="C0123456789",
+ thread_ts="1700000001.123456",
+ recipient_team_id="T0123456789",
+ recipient_user_id="U0123456789",
+ )
+ streamer.append(markdown_text="**hello wo")
+ streamer.append(markdown_text="rld!**")
+ streamer.stop()
+ ```
"""
if self._state == "completed":
raise e.SlackRequestError(f"Cannot stop stream: stream state is {self._state}")
@@ -165,6 +190,5 @@ def _flush_buffer(self, **kwargs) -> SlackResponse:
**kwargs,
markdown_text=self._buffer,
)
-
self._buffer = ""
return response
diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py
index a1afb6f8c..3caabe99b 100644
--- a/slack_sdk/web/client.py
+++ b/slack_sdk/web/client.py
@@ -2903,29 +2903,28 @@ def chat_stream(
thread_ts: str,
recipient_team_id: Optional[str] = None,
recipient_user_id: Optional[str] = None,
- unfurl_links: Optional[bool] = None,
- unfurl_media: Optional[bool] = None,
**kwargs,
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method provides an easy way to stream markdown text using the following endpoints:
- - chat.startStream: Starts a new streaming conversation
- - chat.appendStream: Appends text to an existing streaming conversation
- - chat.stopStream: Stops a streaming conversation
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
+ The following methods are used:
+
+ - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: Size of the internal buffer before automatically flushing (default: 256)
- channel: Channel to stream to
- thread_ts: Thread timestamp to stream to (required)
- recipient_team_id: Team ID of the recipient (for Slack Connect)
- recipient_user_id: User ID of the recipient (for Slack Connect)
- unfurl_links: Whether to unfurl links
- unfurl_media: Whether to unfurl media
- **kwargs: Additional arguments passed to the underlying API calls
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ channel: An encoded ID that represents a channel, private group, or DM.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
+ **kwargs: Additional arguments passed to the underlying API calls.
Returns:
- ChatStreamer instance for managing the stream
+ ChatStream instance for managing the stream
Example:
```python
@@ -2947,8 +2946,6 @@ def chat_stream(
thread_ts=thread_ts,
recipient_team_id=recipient_team_id,
recipient_user_id=recipient_user_id,
- unfurl_links=unfurl_links,
- unfurl_media=unfurl_media,
buffer_size=buffer_size,
**kwargs,
)
diff --git a/tests/slack_sdk/web/test_chat_stream.py b/tests/slack_sdk/web/test_chat_stream.py
index 5b0ecee87..d9571f44f 100644
--- a/tests/slack_sdk/web/test_chat_stream.py
+++ b/tests/slack_sdk/web/test_chat_stream.py
@@ -4,6 +4,7 @@
from urllib.parse import parse_qs, urlparse
from slack_sdk import WebClient
+from slack_sdk.errors import SlackRequestError
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
from tests.slack_sdk.web.mock_web_api_handler import MockHandler
@@ -116,10 +117,10 @@ def test_streams_a_long_message(self):
thread_ts="123.000",
)
streamer.append(markdown_text="**this messag")
- streamer.append(markdown_text="e is")
+ streamer.append(markdown_text="e is", token="xoxb-chat_stream_test_token1")
streamer.append(markdown_text=" bold!")
streamer.append(markdown_text="*")
- streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token")
+ streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token2")
self.assertEqual(self.received_requests.get("/chat.startStream", 0), 1)
self.assertEqual(self.received_requests.get("/chat.appendStream", 0), 1)
@@ -136,10 +137,32 @@ def test_streams_a_long_message(self):
append_request = self.thread.server.chat_stream_requests.get("/chat.appendStream", {})
self.assertEqual(append_request.get("channel"), "C0123456789")
self.assertEqual(append_request.get("markdown_text"), "e is bold!")
+ self.assertEqual(append_request.get("token"), "xoxb-chat_stream_test_token1")
self.assertEqual(append_request.get("ts"), "123.123")
stop_request = self.thread.server.chat_stream_requests.get("/chat.stopStream", {})
self.assertEqual(stop_request.get("channel"), "C0123456789")
self.assertEqual(stop_request.get("markdown_text"), "**")
- self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token")
+ self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")
self.assertEqual(stop_request.get("ts"), "123.123")
+
+ def test_streams_errors_when_appending_to_an_unstarted_stream(self):
+ streamer = self.client.chat_stream(
+ channel="C0123456789",
+ thread_ts="123.000",
+ token="xoxb-chat_stream_test_missing_ts",
+ )
+ with self.assertRaisesRegex(SlackRequestError, r"^Failed to stop stream: stream not started$"):
+ streamer.stop()
+
+ def test_streams_errors_when_appending_to_a_completed_stream(self):
+ streamer = self.client.chat_stream(
+ channel="C0123456789",
+ thread_ts="123.000",
+ )
+ streamer.append(markdown_text="nice!")
+ streamer.stop()
+ with self.assertRaisesRegex(SlackRequestError, r"^Cannot append to stream: stream state is completed$"):
+ streamer.append(markdown_text="more...")
+ with self.assertRaisesRegex(SlackRequestError, r"^Cannot stop stream: stream state is completed$"):
+ streamer.stop()
diff --git a/tests/slack_sdk_async/web/test_async_chat_stream.py b/tests/slack_sdk_async/web/test_async_chat_stream.py
index 01c564ded..48764c825 100644
--- a/tests/slack_sdk_async/web/test_async_chat_stream.py
+++ b/tests/slack_sdk_async/web/test_async_chat_stream.py
@@ -3,6 +3,7 @@
import unittest
from urllib.parse import parse_qs, urlparse
+from slack_sdk.errors import SlackRequestError
from slack_sdk.web.async_client import AsyncWebClient
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
from tests.slack_sdk.web.mock_web_api_handler import MockHandler
@@ -119,10 +120,10 @@ async def test_streams_a_long_message(self):
thread_ts="123.000",
)
await streamer.append(markdown_text="**this messag")
- await streamer.append(markdown_text="e is")
+ await streamer.append(markdown_text="e is", token="xoxb-chat_stream_test_token1")
await streamer.append(markdown_text=" bold!")
await streamer.append(markdown_text="*")
- await streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token")
+ await streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token2")
self.assertEqual(self.received_requests.get("/chat.startStream", 0), 1)
self.assertEqual(self.received_requests.get("/chat.appendStream", 0), 1)
@@ -139,10 +140,34 @@ async def test_streams_a_long_message(self):
append_request = self.thread.server.chat_stream_requests.get("/chat.appendStream", {})
self.assertEqual(append_request.get("channel"), "C0123456789")
self.assertEqual(append_request.get("markdown_text"), "e is bold!")
+ self.assertEqual(append_request.get("token"), "xoxb-chat_stream_test_token1")
self.assertEqual(append_request.get("ts"), "123.123")
stop_request = self.thread.server.chat_stream_requests.get("/chat.stopStream", {})
self.assertEqual(stop_request.get("channel"), "C0123456789")
self.assertEqual(stop_request.get("markdown_text"), "**")
- self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token")
+ self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")
self.assertEqual(stop_request.get("ts"), "123.123")
+
+ @async_test
+ async def test_streams_errors_when_appending_to_an_unstarted_stream(self):
+ streamer = await self.client.chat_stream(
+ channel="C0123456789",
+ thread_ts="123.000",
+ token="xoxb-chat_stream_test_missing_ts",
+ )
+ with self.assertRaisesRegex(SlackRequestError, r"^Failed to stop stream: stream not started$"):
+ await streamer.stop()
+
+ @async_test
+ async def test_streams_errors_when_appending_to_a_completed_stream(self):
+ streamer = await self.client.chat_stream(
+ channel="C0123456789",
+ thread_ts="123.000",
+ )
+ await streamer.append(markdown_text="nice!")
+ await streamer.stop()
+ with self.assertRaisesRegex(SlackRequestError, r"^Cannot append to stream: stream state is completed$"):
+ await streamer.append(markdown_text="more...")
+ with self.assertRaisesRegex(SlackRequestError, r"^Cannot stop stream: stream state is completed$"):
+ await streamer.stop()
diff --git a/tests/slack_sdk_fixture/web_response_chat_stream_test_token.json b/tests/slack_sdk_fixture/web_response_chat_stream_test_missing_ts.json
similarity index 100%
rename from tests/slack_sdk_fixture/web_response_chat_stream_test_token.json
rename to tests/slack_sdk_fixture/web_response_chat_stream_test_missing_ts.json
diff --git a/tests/slack_sdk_fixture/web_response_chat_stream_test_token1.json b/tests/slack_sdk_fixture/web_response_chat_stream_test_token1.json
new file mode 100644
index 000000000..0287aedde
--- /dev/null
+++ b/tests/slack_sdk_fixture/web_response_chat_stream_test_token1.json
@@ -0,0 +1,3 @@
+{
+ "ok": true
+}
diff --git a/tests/slack_sdk_fixture/web_response_chat_stream_test_token2.json b/tests/slack_sdk_fixture/web_response_chat_stream_test_token2.json
new file mode 100644
index 000000000..0287aedde
--- /dev/null
+++ b/tests/slack_sdk_fixture/web_response_chat_stream_test_token2.json
@@ -0,0 +1,3 @@
+{
+ "ok": true
+}
From b7964ad45298062a3a0b11315933db165eb5f7ff Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 16:26:51 -0700
Subject: [PATCH 11/18] style: alphabetical methods
---
scripts/codegen.py | 2 +-
slack_sdk/web/async_client.py | 52 +++++++++++++++++------------------
slack_sdk/web/client.py | 52 +++++++++++++++++------------------
3 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/scripts/codegen.py b/scripts/codegen.py
index b23088b5a..53b6d65e4 100644
--- a/scripts/codegen.py
+++ b/scripts/codegen.py
@@ -120,7 +120,7 @@
)
legacy_source = re.sub(r"= WebClient\(", "= LegacyWebClient(", legacy_source)
legacy_source = re.sub(r"from slack_sdk.web.chat_stream import ChatStream", "", legacy_source)
- legacy_source = re.sub(r"(?s)def chat_stream.*?(?=def\s+chat_stopStream\()", "", legacy_source)
+ legacy_source = re.sub(r"(?s)def chat_stream.*?(?=def)", "", legacy_source)
with open(f"{args.path}/slack_sdk/web/legacy_client.py", "w") as output:
output.write(legacy_source)
diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py
index 74d385129..54146d590 100644
--- a/slack_sdk/web/async_client.py
+++ b/slack_sdk/web/async_client.py
@@ -2905,6 +2905,32 @@ async def chat_startStream(
kwargs = _remove_none_values(kwargs)
return await self.api_call("chat.startStream", json=kwargs)
+ async def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> AsyncSlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return await self.api_call("chat.stopStream", json=kwargs)
+
async def chat_stream(
self,
*,
@@ -2960,32 +2986,6 @@ async def chat_stream(
**kwargs,
)
- async def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> AsyncSlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return await self.api_call("chat.stopStream", json=kwargs)
-
async def chat_unfurl(
self,
*,
diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py
index 3caabe99b..a1bb4397b 100644
--- a/slack_sdk/web/client.py
+++ b/slack_sdk/web/client.py
@@ -2895,6 +2895,32 @@ def chat_startStream(
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
+ def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> SlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return self.api_call("chat.stopStream", json=kwargs)
+
def chat_stream(
self,
*,
@@ -2950,32 +2976,6 @@ def chat_stream(
**kwargs,
)
- def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> SlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return self.api_call("chat.stopStream", json=kwargs)
-
def chat_unfurl(
self,
*,
From 8a8ecb323582a0c23f94fbc92d60fabe7cc7d8ed Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 16:32:21 -0700
Subject: [PATCH 12/18] style: lint
---
docs/reference/index.html | 118 +++++++++++++---------
docs/reference/web/async_chat_stream.html | 62 ++++++++----
docs/reference/web/async_client.html | 118 +++++++++++++---------
docs/reference/web/chat_stream.html | 62 ++++++++----
docs/reference/web/client.html | 118 +++++++++++++---------
docs/reference/web/index.html | 118 +++++++++++++---------
slack_sdk/web/async_chat_stream.py | 25 +++--
slack_sdk/web/async_client.py | 22 ++--
slack_sdk/web/chat_stream.py | 25 +++--
slack_sdk/web/client.py | 22 ++--
10 files changed, 432 insertions(+), 258 deletions(-)
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 76fdfb093..e7185c898 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -3030,6 +3030,32 @@
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
+ def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> SlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return self.api_call("chat.stopStream", json=kwargs)
+
def chat_stream(
self,
*,
@@ -3042,19 +3068,27 @@
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -3085,32 +3119,6 @@
**kwargs,
)
- def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> SlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return self.api_call("chat.stopStream", json=kwargs)
-
def chat_unfurl(
self,
*,
@@ -10421,19 +10429,27 @@ Methods
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -10465,23 +10481,31 @@ Methods
)
Stream markdown text into a conversation.
-
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
-- chat.startStream: Starts a new streaming conversation. Reference.
-- chat.appendStream: Appends text to an existing streaming conversation. Reference.
-- chat.stopStream: Stops a streaming conversation. Reference.
+- chat.startStream: Starts a new streaming conversation.
+Reference.
+- chat.appendStream: Appends text to an existing streaming conversation.
+Reference.
+- chat.stopStream: Stops a streaming conversation.
+Reference.
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
diff --git a/docs/reference/web/async_chat_stream.html b/docs/reference/web/async_chat_stream.html
index 8e9d0ef91..25240ef76 100644
--- a/docs/reference/web/async_chat_stream.html
+++ b/docs/reference/web/async_chat_stream.html
@@ -58,7 +58,8 @@
class AsyncChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+ methods, with automatic buffering and state management.
"""
def __init__(
@@ -81,10 +82,14 @@
client: The WebClient instance to use for API calls.
channel: An encoded ID that represents a channel, private group, or DM.
logger: A logging channel for outputs.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -110,10 +115,12 @@
) -> Optional[AsyncSlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -165,8 +172,10 @@
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -238,7 +247,8 @@
return response
A helper class for streaming markdown text into a conversation using the chat streaming APIs.
-
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+methods, with automatic buffering and state management.
Initialize a new ChatStream instance.
The init method creates a unique ChatStream instance that keeps track of one chat stream.
Args
@@ -250,13 +260,17 @@
Args
logger
- A logging channel for outputs.
thread_ts
-
- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+
- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-
- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+
- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
-
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
**kwargs
- Additional arguments passed to the underlying API calls.
@@ -278,10 +292,12 @@ Methods
) -> Optional[AsyncSlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -322,11 +338,13 @@ Methods
return None
Append to the stream.
-
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+is stopped this method cannot be called.
Args
markdown_text
-- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+what will be appended to the message received so far.
**kwargs
- Additional arguments passed to the underlying API calls.
@@ -369,8 +387,10 @@
Example
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -425,9 +445,11 @@
Args
blocks
- A list of blocks that will be rendered at the bottom of the finalized message.
markdown_text
-
- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+
- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+what will be appended to the message received so far.
metadata
-
- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+
- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs
- Additional arguments passed to the underlying API calls.
diff --git a/docs/reference/web/async_client.html b/docs/reference/web/async_client.html
index 24943a71f..efec8c06e 100644
--- a/docs/reference/web/async_client.html
+++ b/docs/reference/web/async_client.html
@@ -2926,6 +2926,32 @@
kwargs = _remove_none_values(kwargs)
return await self.api_call("chat.startStream", json=kwargs)
+ async def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> AsyncSlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return await self.api_call("chat.stopStream", json=kwargs)
+
async def chat_stream(
self,
*,
@@ -2938,19 +2964,27 @@
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -2981,32 +3015,6 @@
**kwargs,
)
- async def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> AsyncSlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return await self.api_call("chat.stopStream", json=kwargs)
-
async def chat_unfurl(
self,
*,
@@ -10317,19 +10325,27 @@
Methods
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -10361,23 +10377,31 @@
Methods
)
Stream markdown text into a conversation.
-
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
-- chat.startStream: Starts a new streaming conversation. Reference.
-- chat.appendStream: Appends text to an existing streaming conversation. Reference.
-- chat.stopStream: Stops a streaming conversation. Reference.
+- chat.startStream: Starts a new streaming conversation.
+Reference.
+- chat.appendStream: Appends text to an existing streaming conversation.
+Reference.
+- chat.stopStream: Stops a streaming conversation.
+Reference.
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
diff --git a/docs/reference/web/chat_stream.html b/docs/reference/web/chat_stream.html
index 2f4dea425..71715bd93 100644
--- a/docs/reference/web/chat_stream.html
+++ b/docs/reference/web/chat_stream.html
@@ -58,7 +58,8 @@
class ChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+ methods, with automatic buffering and state management.
"""
def __init__(
@@ -81,10 +82,14 @@
client: The WebClient instance to use for API calls.
channel: An encoded ID that represents a channel, private group, or DM.
logger: A logging channel for outputs.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -110,10 +115,12 @@
) -> Optional[SlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -165,8 +172,10 @@
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -238,7 +247,8 @@
return response
A helper class for streaming markdown text into a conversation using the chat streaming APIs.
-
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+
This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+methods, with automatic buffering and state management.
Initialize a new ChatStream instance.
The init method creates a unique ChatStream instance that keeps track of one chat stream.
Args
@@ -250,13 +260,17 @@
Args
logger
- A logging channel for outputs.
thread_ts
-
- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+
- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-
- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+
- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
-
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
**kwargs
- Additional arguments passed to the underlying API calls.
@@ -278,10 +292,12 @@ Methods
) -> Optional[SlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -322,11 +338,13 @@ Methods
return None
Append to the stream.
-
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+
The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+is stopped this method cannot be called.
Args
markdown_text
-- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+what will be appended to the message received so far.
**kwargs
- Additional arguments passed to the underlying API calls.
@@ -369,8 +387,10 @@
Example
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -425,9 +445,11 @@
Args
blocks
- A list of blocks that will be rendered at the bottom of the finalized message.
markdown_text
-
- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+
- Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+what will be appended to the message received so far.
metadata
-
- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+
- JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs
- Additional arguments passed to the underlying API calls.
diff --git a/docs/reference/web/client.html b/docs/reference/web/client.html
index 886ada4ad..45e573e71 100644
--- a/docs/reference/web/client.html
+++ b/docs/reference/web/client.html
@@ -2926,6 +2926,32 @@
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
+ def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> SlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return self.api_call("chat.stopStream", json=kwargs)
+
def chat_stream(
self,
*,
@@ -2938,19 +2964,27 @@
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -2981,32 +3015,6 @@
**kwargs,
)
- def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> SlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return self.api_call("chat.stopStream", json=kwargs)
-
def chat_unfurl(
self,
*,
@@ -10317,19 +10325,27 @@
Methods
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -10361,23 +10377,31 @@
Methods
)
Stream markdown text into a conversation.
-
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
-- chat.startStream: Starts a new streaming conversation. Reference.
-- chat.appendStream: Appends text to an existing streaming conversation. Reference.
-- chat.stopStream: Stops a streaming conversation. Reference.
+- chat.startStream: Starts a new streaming conversation.
+Reference.
+- chat.appendStream: Appends text to an existing streaming conversation.
+Reference.
+- chat.stopStream: Stops a streaming conversation.
+Reference.
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
diff --git a/docs/reference/web/index.html b/docs/reference/web/index.html
index 3a8f81cc6..05fd3d7d6 100644
--- a/docs/reference/web/index.html
+++ b/docs/reference/web/index.html
@@ -3295,6 +3295,32 @@ Raises
kwargs = _remove_none_values(kwargs)
return self.api_call("chat.startStream", json=kwargs)
+ def chat_stopStream(
+ self,
+ *,
+ channel: str,
+ ts: str,
+ markdown_text: Optional[str] = None,
+ blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
+ metadata: Optional[Union[Dict, Metadata]] = None,
+ **kwargs,
+ ) -> SlackResponse:
+ """Stops a streaming conversation.
+ https://api.slack.com/methods/chat.stopStream
+ """
+ kwargs.update(
+ {
+ "channel": channel,
+ "ts": ts,
+ "markdown_text": markdown_text,
+ "blocks": blocks,
+ "metadata": metadata,
+ }
+ )
+ _parse_web_class_objects(kwargs)
+ kwargs = _remove_none_values(kwargs)
+ return self.api_call("chat.stopStream", json=kwargs)
+
def chat_stream(
self,
*,
@@ -3307,19 +3333,27 @@ Raises
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -3350,32 +3384,6 @@ Raises
**kwargs,
)
- def chat_stopStream(
- self,
- *,
- channel: str,
- ts: str,
- markdown_text: Optional[str] = None,
- blocks: Optional[Union[str, Sequence[Union[Dict, Block]]]] = None,
- metadata: Optional[Union[Dict, Metadata]] = None,
- **kwargs,
- ) -> SlackResponse:
- """Stops a streaming conversation.
- https://api.slack.com/methods/chat.stopStream
- """
- kwargs.update(
- {
- "channel": channel,
- "ts": ts,
- "markdown_text": markdown_text,
- "blocks": blocks,
- "metadata": metadata,
- }
- )
- _parse_web_class_objects(kwargs)
- kwargs = _remove_none_values(kwargs)
- return self.api_call("chat.stopStream", json=kwargs)
-
def chat_unfurl(
self,
*,
@@ -10686,19 +10694,27 @@ Methods
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
@@ -10730,23 +10746,31 @@ Methods
)
Stream markdown text into a conversation.
-
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+
This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
-- chat.startStream: Starts a new streaming conversation. Reference.
-- chat.appendStream: Appends text to an existing streaming conversation. Reference.
-- chat.stopStream: Stops a streaming conversation. Reference.
+- chat.startStream: Starts a new streaming conversation.
+Reference.
+- chat.appendStream: Appends text to an existing streaming conversation.
+Reference.
+- chat.stopStream: Stops a streaming conversation.
+Reference.
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
-- Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
+- Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+request.
recipient_team_id
-- The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+- The encoded ID of the team the user receiving the streaming text belongs to. Required when
+streaming to channels.
recipient_user_id
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs
diff --git a/slack_sdk/web/async_chat_stream.py b/slack_sdk/web/async_chat_stream.py
index a94c8d00b..85696598b 100644
--- a/slack_sdk/web/async_chat_stream.py
+++ b/slack_sdk/web/async_chat_stream.py
@@ -24,7 +24,8 @@
class AsyncChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+ methods, with automatic buffering and state management.
"""
def __init__(
@@ -47,10 +48,14 @@ def __init__(
client: The WebClient instance to use for API calls.
channel: An encoded ID that represents a channel, private group, or DM.
logger: A logging channel for outputs.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -76,10 +81,12 @@ async def append(
) -> Optional[AsyncSlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -131,8 +138,10 @@ async def stop(
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py
index 54146d590..aead149cd 100644
--- a/slack_sdk/web/async_client.py
+++ b/slack_sdk/web/async_client.py
@@ -2943,19 +2943,27 @@ async def chat_stream(
) -> AsyncChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
diff --git a/slack_sdk/web/chat_stream.py b/slack_sdk/web/chat_stream.py
index 47d77b450..8b2f3bb9b 100644
--- a/slack_sdk/web/chat_stream.py
+++ b/slack_sdk/web/chat_stream.py
@@ -14,7 +14,8 @@
class ChatStream:
"""A helper class for streaming markdown text into a conversation using the chat streaming APIs.
- This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API methods, with automatic buffering and state management.
+ This class provides a convenient interface for the chat.startStream, chat.appendStream, and chat.stopStream API
+ methods, with automatic buffering and state management.
"""
def __init__(
@@ -37,10 +38,14 @@ def __init__(
client: The WebClient instance to use for API calls.
channel: An encoded ID that represents a channel, private group, or DM.
logger: A logging channel for outputs.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -66,10 +71,12 @@ def append(
) -> Optional[SlackResponse]:
"""Append to the stream.
- The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream is stopped this method cannot be called.
+ The "append" method appends to the chat stream being used. This method can be called multiple times. After the stream
+ is stopped this method cannot be called.
Args:
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
@@ -121,8 +128,10 @@ def stop(
Args:
blocks: A list of blocks that will be rendered at the bottom of the finalized message.
- markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is what will be appended to the message received so far.
- metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you post to Slack is accessible to any app or user who is a member of that workspace.
+ markdown_text: Accepts message text formatted in markdown. Limit this field to 12,000 characters. This text is
+ what will be appended to the message received so far.
+ metadata: JSON object with event_type and event_payload fields, presented as a URL-encoded string. Metadata you
+ post to Slack is accessible to any app or user who is a member of that workspace.
**kwargs: Additional arguments passed to the underlying API calls.
Returns:
diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py
index a1bb4397b..cc09df3fe 100644
--- a/slack_sdk/web/client.py
+++ b/slack_sdk/web/client.py
@@ -2933,19 +2933,27 @@ def chat_stream(
) -> ChatStream:
"""Stream markdown text into a conversation.
- This method starts a new chat stream in a coversation that can be appended to. After appending an entire message, the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
+ This method starts a new chat stream in a coversation that can be appended to. After appending an entire message,
+ the stream can be stopped with concluding arguments such as "blocks" for gathering feedback.
The following methods are used:
- - chat.startStream: Starts a new streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
- - chat.appendStream: Appends text to an existing streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
- - chat.stopStream: Stops a streaming conversation. [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
+ - chat.startStream: Starts a new streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.startStream).
+ - chat.appendStream: Appends text to an existing streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.appendStream).
+ - chat.stopStream: Stops a streaming conversation.
+ [Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits. Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
+ Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
- thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user request.
- recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when streaming to channels.
+ thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
+ request.
+ recipient_team_id: The encoded ID of the team the user receiving the streaming text belongs to. Required when
+ streaming to channels.
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
**kwargs: Additional arguments passed to the underlying API calls.
From a962196ad16522a70093dcc79feac85be5d2fd18 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 16:38:58 -0700
Subject: [PATCH 13/18] style: codegen without changing legacy client
---
scripts/codegen.py | 2 +-
slack_sdk/web/legacy_client.py | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/codegen.py b/scripts/codegen.py
index 53b6d65e4..3633faf35 100644
--- a/scripts/codegen.py
+++ b/scripts/codegen.py
@@ -119,7 +119,7 @@
legacy_source,
)
legacy_source = re.sub(r"= WebClient\(", "= LegacyWebClient(", legacy_source)
- legacy_source = re.sub(r"from slack_sdk.web.chat_stream import ChatStream", "", legacy_source)
+ legacy_source = re.sub(r"^from slack_sdk.web.chat_stream import ChatStream\n", "", legacy_source, flags=re.MULTILINE)
legacy_source = re.sub(r"(?s)def chat_stream.*?(?=def)", "", legacy_source)
with open(f"{args.path}/slack_sdk/web/legacy_client.py", "w") as output:
output.write(legacy_source)
diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py
index 1eeee1f40..29ef99064 100644
--- a/slack_sdk/web/legacy_client.py
+++ b/slack_sdk/web/legacy_client.py
@@ -21,7 +21,6 @@
import slack_sdk.errors as e
from slack_sdk.models.views import View
-
from ..models.attachments import Attachment
from ..models.blocks import Block
from ..models.metadata import Metadata
From 82d1495f139b2f4f51f51bf594d30db1bc0e33a8 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Wed, 1 Oct 2025 19:48:56 -0700
Subject: [PATCH 14/18] test: remove codegen reminent
---
tests/slack_sdk/web/test_chat_stream.py | 4 ----
tests/slack_sdk_async/web/test_async_chat_stream.py | 4 ----
2 files changed, 8 deletions(-)
diff --git a/tests/slack_sdk/web/test_chat_stream.py b/tests/slack_sdk/web/test_chat_stream.py
index d9571f44f..596e9c84a 100644
--- a/tests/slack_sdk/web/test_chat_stream.py
+++ b/tests/slack_sdk/web/test_chat_stream.py
@@ -1,5 +1,4 @@
import json
-import re
import unittest
from urllib.parse import parse_qs, urlparse
@@ -79,9 +78,6 @@ def setUp(self):
def tearDown(self):
cleanup_mock_web_api_server(self)
- pattern_for_language = re.compile("python/(\\S+)", re.IGNORECASE)
- pattern_for_package_identifier = re.compile("slackclient/(\\S+)")
-
def test_streams_a_short_message(self):
streamer = self.client.chat_stream(
channel="C0123456789",
diff --git a/tests/slack_sdk_async/web/test_async_chat_stream.py b/tests/slack_sdk_async/web/test_async_chat_stream.py
index 48764c825..6eee84119 100644
--- a/tests/slack_sdk_async/web/test_async_chat_stream.py
+++ b/tests/slack_sdk_async/web/test_async_chat_stream.py
@@ -1,5 +1,4 @@
import json
-import re
import unittest
from urllib.parse import parse_qs, urlparse
@@ -80,9 +79,6 @@ def setUp(self):
def tearDown(self):
cleanup_mock_web_api_server(self)
- pattern_for_language = re.compile("python/(\\S+)", re.IGNORECASE)
- pattern_for_package_identifier = re.compile("slackclient/(\\S+)")
-
@async_test
async def test_streams_a_short_message(self):
streamer = await self.client.chat_stream(
From dbe397fd1b95a7315a46b3531b08701b990fffa2 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Thu, 2 Oct 2025 09:37:51 -0700
Subject: [PATCH 15/18] docs: make the buffered methods clear in reference
Co-authored-by: Michael Brooks
---
slack_sdk/web/client.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py
index cc09df3fe..0cf6eb605 100644
--- a/slack_sdk/web/client.py
+++ b/slack_sdk/web/client.py
@@ -2946,7 +2946,7 @@ def chat_stream(
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this value
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
From 702e19cec6be9462688fc7d392b14dae6d114756 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Thu, 2 Oct 2025 09:42:05 -0700
Subject: [PATCH 16/18] docs: match correct defaults with linebreaks for lint
---
slack_sdk/web/chat_stream.py | 1 -
slack_sdk/web/client.py | 6 +++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/slack_sdk/web/chat_stream.py b/slack_sdk/web/chat_stream.py
index 8b2f3bb9b..1a379c9cb 100644
--- a/slack_sdk/web/chat_stream.py
+++ b/slack_sdk/web/chat_stream.py
@@ -45,7 +45,6 @@ def __init__(
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py
index 0cf6eb605..f95a2a726 100644
--- a/slack_sdk/web/client.py
+++ b/slack_sdk/web/client.py
@@ -2946,9 +2946,9 @@ def chat_stream(
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
From dc88b0325d15d9b174a850860ca8bc891d54ba20 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Thu, 2 Oct 2025 09:56:48 -0700
Subject: [PATCH 17/18] docs: update generated docs
---
docs/reference/index.html | 18 +++++++++---------
docs/reference/web/async_chat_stream.html | 4 +---
docs/reference/web/async_client.html | 18 +++++++++---------
docs/reference/web/chat_stream.html | 4 +---
docs/reference/web/client.html | 18 +++++++++---------
docs/reference/web/index.html | 18 +++++++++---------
slack_sdk/web/async_chat_stream.py | 1 -
slack_sdk/web/async_client.py | 6 +++---
8 files changed, 41 insertions(+), 46 deletions(-)
diff --git a/docs/reference/index.html b/docs/reference/index.html
index e7185c898..3cfd45f3f 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -3081,9 +3081,9 @@
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10442,9 +10442,9 @@ Methods
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10495,9 +10495,9 @@ Methods
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+- The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+limits. Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
diff --git a/docs/reference/web/async_chat_stream.html b/docs/reference/web/async_chat_stream.html
index 25240ef76..ca7bf2506 100644
--- a/docs/reference/web/async_chat_stream.html
+++ b/docs/reference/web/async_chat_stream.html
@@ -89,7 +89,6 @@
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -269,8 +268,7 @@ Args
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
**kwargs
- Additional arguments passed to the underlying API calls.
diff --git a/docs/reference/web/async_client.html b/docs/reference/web/async_client.html
index efec8c06e..7a46cf18c 100644
--- a/docs/reference/web/async_client.html
+++ b/docs/reference/web/async_client.html
@@ -2977,9 +2977,9 @@
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10338,9 +10338,9 @@ Methods
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10391,9 +10391,9 @@ Methods
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+- The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+limits. Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
diff --git a/docs/reference/web/chat_stream.html b/docs/reference/web/chat_stream.html
index 71715bd93..94d96e5eb 100644
--- a/docs/reference/web/chat_stream.html
+++ b/docs/reference/web/chat_stream.html
@@ -89,7 +89,6 @@
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
@@ -269,8 +268,7 @@ Args
- The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size
- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
**kwargs
- Additional arguments passed to the underlying API calls.
diff --git a/docs/reference/web/client.html b/docs/reference/web/client.html
index 45e573e71..162df0964 100644
--- a/docs/reference/web/client.html
+++ b/docs/reference/web/client.html
@@ -2977,9 +2977,9 @@
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10338,9 +10338,9 @@
Methods
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10391,9 +10391,9 @@
Methods
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+- The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+limits. Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
diff --git a/docs/reference/web/index.html b/docs/reference/web/index.html
index 05fd3d7d6..c2df7f11f 100644
--- a/docs/reference/web/index.html
+++ b/docs/reference/web/index.html
@@ -3346,9 +3346,9 @@ Raises
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10707,9 +10707,9 @@ Methods
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
@@ -10760,9 +10760,9 @@ Methods
Args
buffer_size
-- The length of markdown_text to buffer in-memory before calling a method. Increasing this value
-decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
-Default: 256.
+- The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+limits. Default: 256.
channel
- An encoded ID that represents a channel, private group, or DM.
thread_ts
diff --git a/slack_sdk/web/async_chat_stream.py b/slack_sdk/web/async_chat_stream.py
index 85696598b..4661f19dd 100644
--- a/slack_sdk/web/async_chat_stream.py
+++ b/slack_sdk/web/async_chat_stream.py
@@ -55,7 +55,6 @@ def __init__(
recipient_user_id: The encoded ID of the user to receive the streaming text. Required when streaming to channels.
buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
**kwargs: Additional arguments passed to the underlying API calls.
"""
self._client = client
diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py
index aead149cd..f4aa8a17f 100644
--- a/slack_sdk/web/async_client.py
+++ b/slack_sdk/web/async_client.py
@@ -2956,9 +2956,9 @@ async def chat_stream(
[Reference](https://docs.slack.dev/reference/methods/chat.stopStream).
Args:
- buffer_size: The length of markdown_text to buffer in-memory before calling a method. Increasing this value
- decreases the number of method calls made for the same amount of text, which is useful to avoid rate limits.
- Default: 256.
+ buffer_size: The length of markdown_text to buffer in-memory before calling a stream method. Increasing this
+ value decreases the number of method calls made for the same amount of text, which is useful to avoid rate
+ limits. Default: 256.
channel: An encoded ID that represents a channel, private group, or DM.
thread_ts: Provide another message's ts value to reply to. Streamed messages should always be replies to a user
request.
From 38ec262cce8dc312d2167dbde582e62ea2b80ed7 Mon Sep 17 00:00:00 2001
From: Eden Zimbelman
Date: Thu, 2 Oct 2025 09:57:22 -0700
Subject: [PATCH 18/18] test: confirm context actions can be sent with stop
---
tests/slack_sdk/web/test_chat_stream.py | 26 ++++++++++++++++++-
.../web/test_async_chat_stream.py | 26 ++++++++++++++++++-
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/tests/slack_sdk/web/test_chat_stream.py b/tests/slack_sdk/web/test_chat_stream.py
index 596e9c84a..75c13c8c2 100644
--- a/tests/slack_sdk/web/test_chat_stream.py
+++ b/tests/slack_sdk/web/test_chat_stream.py
@@ -4,6 +4,9 @@
from slack_sdk import WebClient
from slack_sdk.errors import SlackRequestError
+from slack_sdk.models.blocks.basic_components import FeedbackButtonObject
+from slack_sdk.models.blocks.block_elements import FeedbackButtonsElement, IconButtonElement
+from slack_sdk.models.blocks.blocks import ContextActionsBlock
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
from tests.slack_sdk.web.mock_web_api_handler import MockHandler
@@ -116,7 +119,24 @@ def test_streams_a_long_message(self):
streamer.append(markdown_text="e is", token="xoxb-chat_stream_test_token1")
streamer.append(markdown_text=" bold!")
streamer.append(markdown_text="*")
- streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token2")
+ streamer.stop(
+ blocks=[
+ ContextActionsBlock(
+ elements=[
+ FeedbackButtonsElement(
+ positive_button=FeedbackButtonObject(text="good", value="+1"),
+ negative_button=FeedbackButtonObject(text="bad", value="-1"),
+ ),
+ IconButtonElement(
+ icon="trash",
+ text="delete",
+ ),
+ ],
+ )
+ ],
+ markdown_text="*",
+ token="xoxb-chat_stream_test_token2",
+ )
self.assertEqual(self.received_requests.get("/chat.startStream", 0), 1)
self.assertEqual(self.received_requests.get("/chat.appendStream", 0), 1)
@@ -137,6 +157,10 @@ def test_streams_a_long_message(self):
self.assertEqual(append_request.get("ts"), "123.123")
stop_request = self.thread.server.chat_stream_requests.get("/chat.stopStream", {})
+ self.assertEqual(
+ json.dumps(stop_request.get("blocks")),
+ '[{"elements": [{"negative_button": {"text": {"emoji": true, "text": "bad", "type": "plain_text"}, "value": "-1"}, "positive_button": {"text": {"emoji": true, "text": "good", "type": "plain_text"}, "value": "+1"}, "type": "feedback_buttons"}, {"icon": "trash", "text": {"emoji": true, "text": "delete", "type": "plain_text"}, "type": "icon_button"}], "type": "context_actions"}]',
+ )
self.assertEqual(stop_request.get("channel"), "C0123456789")
self.assertEqual(stop_request.get("markdown_text"), "**")
self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")
diff --git a/tests/slack_sdk_async/web/test_async_chat_stream.py b/tests/slack_sdk_async/web/test_async_chat_stream.py
index 6eee84119..212fee1e2 100644
--- a/tests/slack_sdk_async/web/test_async_chat_stream.py
+++ b/tests/slack_sdk_async/web/test_async_chat_stream.py
@@ -3,6 +3,9 @@
from urllib.parse import parse_qs, urlparse
from slack_sdk.errors import SlackRequestError
+from slack_sdk.models.blocks.basic_components import FeedbackButtonObject
+from slack_sdk.models.blocks.block_elements import FeedbackButtonsElement, IconButtonElement
+from slack_sdk.models.blocks.blocks import ContextActionsBlock
from slack_sdk.web.async_client import AsyncWebClient
from tests.mock_web_api_server import cleanup_mock_web_api_server, setup_mock_web_api_server
from tests.slack_sdk.web.mock_web_api_handler import MockHandler
@@ -119,7 +122,24 @@ async def test_streams_a_long_message(self):
await streamer.append(markdown_text="e is", token="xoxb-chat_stream_test_token1")
await streamer.append(markdown_text=" bold!")
await streamer.append(markdown_text="*")
- await streamer.stop(markdown_text="*", token="xoxb-chat_stream_test_token2")
+ await streamer.stop(
+ blocks=[
+ ContextActionsBlock(
+ elements=[
+ FeedbackButtonsElement(
+ positive_button=FeedbackButtonObject(text="good", value="+1"),
+ negative_button=FeedbackButtonObject(text="bad", value="-1"),
+ ),
+ IconButtonElement(
+ icon="trash",
+ text="delete",
+ ),
+ ],
+ )
+ ],
+ markdown_text="*",
+ token="xoxb-chat_stream_test_token2",
+ )
self.assertEqual(self.received_requests.get("/chat.startStream", 0), 1)
self.assertEqual(self.received_requests.get("/chat.appendStream", 0), 1)
@@ -140,6 +160,10 @@ async def test_streams_a_long_message(self):
self.assertEqual(append_request.get("ts"), "123.123")
stop_request = self.thread.server.chat_stream_requests.get("/chat.stopStream", {})
+ self.assertEqual(
+ json.dumps(stop_request.get("blocks")),
+ '[{"elements": [{"negative_button": {"text": {"emoji": true, "text": "bad", "type": "plain_text"}, "value": "-1"}, "positive_button": {"text": {"emoji": true, "text": "good", "type": "plain_text"}, "value": "+1"}, "type": "feedback_buttons"}, {"icon": "trash", "text": {"emoji": true, "text": "delete", "type": "plain_text"}, "type": "icon_button"}], "type": "context_actions"}]',
+ )
self.assertEqual(stop_request.get("channel"), "C0123456789")
self.assertEqual(stop_request.get("markdown_text"), "**")
self.assertEqual(stop_request.get("token"), "xoxb-chat_stream_test_token2")