1414assistant = Assistant ()
1515
1616
17- # This listener is invoked when a human user opened an assistant thread
1817@assistant .thread_started
1918def start_assistant_thread (
2019 say : Say ,
2120 get_thread_context : GetThreadContext ,
2221 set_suggested_prompts : SetSuggestedPrompts ,
2322 logger : logging .Logger ,
2423):
24+ """
25+ Handle the assistant thread start event by greeting the user and setting suggested prompts.
26+
27+ Args:
28+ say: Function to send messages to the thread from the app
29+ get_thread_context: Function to retrieve thread context information
30+ set_suggested_prompts: Function to configure suggested prompt options
31+ logger: Logger instance for error tracking
32+ """
2533 try :
2634 say ("How can I help you?" )
2735
@@ -65,6 +73,18 @@ def respond_in_assistant_thread(
6573 say : Say ,
6674 set_status : SetStatus ,
6775):
76+ """
77+ Handles when users send messages or select a prompt in an assistant thread and generate AI responses:
78+
79+ Args:
80+ client: Slack WebClient for making API calls
81+ context: Bolt context containing channel and thread information
82+ get_thread_context: Function to retrieve thread context (e.g., referred channel)
83+ logger: Logger instance for error tracking
84+ payload: Event payload with message details (channel, user, text, etc.)
85+ say: Function to send messages to the thread
86+ set_status: Function to update the assistant's status
87+ """
6888 try :
6989 channel_id = payload ["channel" ]
7090 team_id = payload ["team" ]
@@ -84,8 +104,6 @@ def respond_in_assistant_thread(
84104 )
85105
86106 if user_message == "Can you generate a brief summary of the referred channel?" :
87- # the logic here requires the additional bot scopes:
88- # channels:join, channels:history, groups:history
89107 thread_context = get_thread_context ()
90108 referred_channel_id = thread_context .get ("channel_id" )
91109 try :
0 commit comments