@@ -48,7 +48,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
4848< dl >
4949< dt id ="slack_bolt.app.app.App "> < code class ="flex name class ">
5050< span > class < span class ="ident "> App</ span > </ span >
51- < span > (</ span > < span > *,< br > logger: logging.Logger | None = None,< br > name: str | None = None,< br > process_before_response: bool = False,< br > raise_error_for_unhandled_request: bool = False,< br > signing_secret: str | None = None,< br > token: str | None = None,< br > token_verification_enabled: bool = True,< br > client: slack_sdk.web.client.WebClient | None = None,< br > before_authorize: < a title ="slack_bolt.middleware.middleware.Middleware " href ="../middleware/middleware.html#slack_bolt.middleware.middleware.Middleware "> Middleware</ a > | Callable[..., Any] | None = None,< br > authorize: Callable[..., < a title ="slack_bolt.authorization.authorize_result.AuthorizeResult " href ="../authorization/authorize_result.html#slack_bolt.authorization.authorize_result.AuthorizeResult "> AuthorizeResult</ a > ] | None = None,< br > user_facing_authorize_error_message: str | None = None,< br > installation_store: slack_sdk.oauth.installation_store.installation_store.InstallationStore | None = None,< br > installation_store_bot_only: bool | None = None,< br > request_verification_enabled: bool = True,< br > ignoring_self_events_enabled: bool = True,< br > ignoring_self_assistant_message_events_enabled: bool = True,< br > ssl_check_enabled: bool = True,< br > url_verification_enabled: bool = True,< br > attaching_function_token_enabled: bool = True,< br > oauth_settings: < a title ="slack_bolt.oauth.oauth_settings.OAuthSettings " href ="../oauth/oauth_settings.html#slack_bolt.oauth.oauth_settings.OAuthSettings "> OAuthSettings</ a > | None = None,< br > oauth_flow: < a title ="slack_bolt.oauth.oauth_flow.OAuthFlow " href ="../oauth/oauth_flow.html#slack_bolt.oauth.oauth_flow.OAuthFlow "> OAuthFlow</ a > | None = None,< br > verification_token: str | None = None,< br > listener_executor: concurrent.futures._base.Executor | None = None,< br > assistant_thread_context_store: < a title ="slack_bolt.context.assistant.thread_context_store.store.AssistantThreadContextStore " href ="../context/assistant/thread_context_store/store.html#slack_bolt.context.assistant.thread_context_store.store.AssistantThreadContextStore "> AssistantThreadContextStore</ a > | None = None)</ span >
51+ < span > (</ span > < span > *,< br > logger: logging.Logger | None = None,< br > name: str | None = None,< br > process_before_response: bool = False,< br > raise_error_for_unhandled_request: bool = False,< br > signing_secret: str | None = None,< br > token: str | None = None,< br > token_verification_enabled: bool = True,< br > client: slack_sdk.web.client.WebClient | None = None,< br > before_authorize: < a title ="slack_bolt.middleware.middleware.Middleware " href ="../middleware/middleware.html#slack_bolt.middleware.middleware.Middleware "> Middleware</ a > | Callable[..., Any] | None = None,< br > authorize: Callable[..., < a title ="slack_bolt.authorization.authorize_result.AuthorizeResult " href ="../authorization/authorize_result.html#slack_bolt.authorization.authorize_result.AuthorizeResult "> AuthorizeResult</ a > ] | None = None,< br > user_facing_authorize_error_message: str | None = None,< br > installation_store: slack_sdk.oauth.installation_store.installation_store.InstallationStore | None = None,< br > installation_store_bot_only: bool | None = None,< br > request_verification_enabled: bool = True,< br > ignoring_self_events_enabled: bool = True,< br > ignoring_self_assistant_message_events_enabled: bool = True,< br > ssl_check_enabled: bool = True,< br > url_verification_enabled: bool = True,< br > attaching_function_token_enabled: bool = True,< br > oauth_settings: < a title ="slack_bolt.oauth.oauth_settings.OAuthSettings " href ="../oauth/oauth_settings.html#slack_bolt.oauth.oauth_settings.OAuthSettings "> OAuthSettings</ a > | None = None,< br > oauth_flow: < a title ="slack_bolt.oauth.oauth_flow.OAuthFlow " href ="../oauth/oauth_flow.html#slack_bolt.oauth.oauth_flow.OAuthFlow "> OAuthFlow</ a > | None = None,< br > verification_token: str | None = None,< br > listener_executor: concurrent.futures._base.Executor | None = None,< br > assistant_thread_context_store: < a title ="slack_bolt.context.assistant.thread_context_store.store.AssistantThreadContextStore " href ="../context/assistant/thread_context_store/store.html#slack_bolt.context.assistant.thread_context_store.store.AssistantThreadContextStore "> AssistantThreadContextStore</ a > | None = None,< br > attaching_conversation_kwargs_enabled: bool = True)</ span >
5252</ code > </ dt >
5353< dd >
5454< details class ="source ">
@@ -95,6 +95,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
9595 listener_executor: Optional[Executor] = None,
9696 # for AI Agents & Assistants
9797 assistant_thread_context_store: Optional[AssistantThreadContextStore] = None,
98+ attaching_conversation_kwargs_enabled: bool = True,
9899 ):
99100 """Bolt App that provides functionalities to register middleware/listeners.
100101
@@ -315,6 +316,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
315316 listener_executor = ThreadPoolExecutor(max_workers=5)
316317
317318 self._assistant_thread_context_store = assistant_thread_context_store
319+ self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled
318320
319321 self._process_before_response = process_before_response
320322 self._listener_runner = ThreadListenerRunner(
@@ -799,10 +801,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
799801 middleware: A list of lister middleware functions.
800802 Only when all the middleware call `next()` method, the listener function can be invoked.
801803 """
804+ middleware = list(middleware) if middleware else []
802805
803806 def __call__(*args, **kwargs):
804807 functions = self._to_listener_functions(kwargs) if kwargs else list(args)
805808 primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger)
809+ if self._attaching_conversation_kwargs_enabled:
810+ middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
806811 return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
807812
808813 return __call__
@@ -860,6 +865,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
860865 primary_matcher = builtin_matchers.message_event(
861866 keyword=keyword, constraints=constraints, base_logger=self._base_logger
862867 )
868+ if self._attaching_conversation_kwargs_enabled:
869+ middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
863870 middleware.insert(0, MessageListenerMatches(keyword))
864871 return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
865872
@@ -1356,20 +1363,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
13561363 # It is intended for apps that start lazy listeners from their custom global middleware.
13571364 req.context["listener_runner"] = self.listener_runner
13581365
1359- # For AI Agents & Assistants
1360- if is_assistant_event(req.body):
1361- assistant = AssistantUtilities(
1362- payload=to_event(req.body), # type:ignore[arg-type]
1363- context=req.context,
1364- thread_context_store=self._assistant_thread_context_store,
1365- )
1366- req.context["say"] = assistant.say
1367- req.context["set_status"] = assistant.set_status
1368- req.context["set_title"] = assistant.set_title
1369- req.context["set_suggested_prompts"] = assistant.set_suggested_prompts
1370- req.context["get_thread_context"] = assistant.get_thread_context
1371- req.context["save_thread_context"] = assistant.save_thread_context
1372-
13731366 @staticmethod
13741367 def _to_listener_functions(
13751368 kwargs: dict,
@@ -1415,7 +1408,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
14151408 CustomListener(
14161409 app_name=self.name,
14171410 ack_function=functions.pop(0),
1418- lazy_functions=functions, # type:ignore[arg-type]
1411+ lazy_functions=functions, # type: ignore[arg-type]
14191412 matchers=listener_matchers,
14201413 middleware=listener_middleware,
14211414 auto_acknowledgement=auto_acknowledgement,
@@ -2203,10 +2196,13 @@ <h2 id="args">Args</h2>
22032196 middleware: A list of lister middleware functions.
22042197 Only when all the middleware call `next()` method, the listener function can be invoked.
22052198 """
2199+ middleware = list(middleware) if middleware else []
22062200
22072201 def __call__(*args, **kwargs):
22082202 functions = self._to_listener_functions(kwargs) if kwargs else list(args)
22092203 primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger)
2204+ if self._attaching_conversation_kwargs_enabled:
2205+ middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
22102206 return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
22112207
22122208 return __call__</ code > </ pre >
@@ -2410,6 +2406,8 @@ <h2 id="args">Args</h2>
24102406 primary_matcher = builtin_matchers.message_event(
24112407 keyword=keyword, constraints=constraints, base_logger=self._base_logger
24122408 )
2409+ if self._attaching_conversation_kwargs_enabled:
2410+ middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
24132411 middleware.insert(0, MessageListenerMatches(keyword))
24142412 return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)
24152413
0 commit comments