From 2f707b06fdfa4179cffc76fe3efe65e9c5c8463d Mon Sep 17 00:00:00 2001 From: Luke Russell Date: Tue, 24 Mar 2026 16:19:46 -0700 Subject: [PATCH] go --- docs/english/web.md | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/english/web.md b/docs/english/web.md index b776ce5fd..b0afc7da6 100644 --- a/docs/english/web.md +++ b/docs/english/web.md @@ -61,11 +61,8 @@ You can have your app's messages stream in to replicate conventional AI chatbot * [`chat_appendStream`](/reference/methods/chat.appendStream) * [`chat_stopStream`](/reference/methods/chat.stopStream) -:::tip[The Python Slack SDK provides a [`chat_stream()`](https://docs.slack.dev/tools/python-slack-sdk/reference/web/client.html#slack_sdk.web.client.WebClient.chat_stream) helper utility to streamline calling these methods.] -See the [_Streaming messages_](/tools/bolt-python/concepts/message-sending#streaming-messages) section of the Bolt for Python docs for implementation instructions. - -::: +You can streamline calling these methods by using the [`chat_stream()`](#chat_stream) helper. #### Starting the message stream {#starting-stream} @@ -161,6 +158,30 @@ def handle_message(message, client): See [Formatting messages with Block Kit](#block-kit) below for more details on using Block Kit with messages. +#### Using the `chat_stream()` helper {#chat_stream} + +The Python Slack SDK provides a [`chat_stream()`](https://docs.slack.dev/tools/python-slack-sdk/reference/web/client.html#slack_sdk.web.client.WebClient.chat_stream) helper utility to streamline calling these methods. Here's an excerpt from our [Assistant template app](https://github.com/slack-samples/bolt-python-assistant-template): + +```python +streamer = client.chat_stream( + channel=channel_id, + recipient_team_id=team_id, + recipient_user_id=user_id, + thread_ts=thread_ts, +) + +# Loop over OpenAI response stream +# https://platform.openai.com/docs/api-reference/responses/create +for event in returned_message: + if event.type == "response.output_text.delta": + streamer.append(markdown_text=f"{event.delta}") + else: + continue + +feedback_block = create_feedback_block() +streamer.stop() +``` + ## Formatting messages with Block Kit {#block-kit} Messages posted from apps can contain more than just text; they can also include full user interfaces composed of blocks using [Block Kit](/block-kit).