11import logging
2- from typing import List , Dict
3- from slack_bolt import Assistant , BoltContext , Say , SetSuggestedPrompts
2+ from typing import Dict , List
3+
4+ from slack_bolt import Assistant , BoltContext , Say , SetStatus , SetSuggestedPrompts
45from slack_bolt .context .get_thread_context import GetThreadContext
56from slack_sdk import WebClient
67from slack_sdk .errors import SlackApiError
@@ -57,12 +58,13 @@ def start_assistant_thread(
5758# This listener is invoked when the human user sends a reply in the assistant thread
5859@assistant .user_message
5960def respond_in_assistant_thread (
60- payload : dict ,
61- logger : logging .Logger ,
61+ client : WebClient ,
6262 context : BoltContext ,
6363 get_thread_context : GetThreadContext ,
64- client : WebClient ,
64+ logger : logging .Logger ,
65+ payload : dict ,
6566 say : Say ,
67+ set_status : SetStatus ,
6668):
6769 try :
6870 channel_id = payload ["channel" ]
@@ -71,6 +73,17 @@ def respond_in_assistant_thread(
7173 user_id = payload ["user" ]
7274 user_message = payload ["text" ]
7375
76+ set_status (
77+ status = "Drafting..." ,
78+ loading_messages = [
79+ "Teaching the hamsters to type faster…" ,
80+ "Untangling the internet cables…" ,
81+ "Consulting the office goldfish…" ,
82+ "Polishing up the response just for you…" ,
83+ "Convincing the AI to stop overthinking…" ,
84+ ],
85+ )
86+
7487 if user_message == "Can you generate a brief summary of the referred channel?" :
7588 # the logic here requires the additional bot scopes:
7689 # channels:join, channels:history, groups:history
@@ -106,10 +119,6 @@ def respond_in_assistant_thread(
106119
107120 returned_message = call_llm (messages_in_thread )
108121
109- client .assistant_threads_setStatus (
110- channel_id = channel_id , thread_ts = thread_ts , status = "Bolt is typing" , loading_messages = loading_messages
111- )
112-
113122 stream_response = client .chat_startStream (
114123 channel = channel_id ,
115124 recipient_team_id = team_id ,
0 commit comments