Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions docs/reference/app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="slack_bolt.app.app.App"><code class="flex name class">
<span>class <span class="ident">App</span></span>
<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>
<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>
</code></dt>
<dd>
<details class="source">
Expand Down Expand Up @@ -95,6 +95,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
listener_executor: Optional[Executor] = None,
# for AI Agents &amp; Assistants
assistant_thread_context_store: Optional[AssistantThreadContextStore] = None,
attaching_conversation_kwargs_enabled: bool = True,
):
&#34;&#34;&#34;Bolt App that provides functionalities to register middleware/listeners.

Expand Down Expand Up @@ -315,6 +316,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
listener_executor = ThreadPoolExecutor(max_workers=5)

self._assistant_thread_context_store = assistant_thread_context_store
self._attaching_conversation_kwargs_enabled = attaching_conversation_kwargs_enabled

self._process_before_response = process_before_response
self._listener_runner = ThreadListenerRunner(
Expand Down Expand Up @@ -799,10 +801,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
middleware: A list of lister middleware functions.
Only when all the middleware call `next()` method, the listener function can be invoked.
&#34;&#34;&#34;
middleware = list(middleware) if middleware else []

def __call__(*args, **kwargs):
functions = self._to_listener_functions(kwargs) if kwargs else list(args)
primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger)
if self._attaching_conversation_kwargs_enabled:
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)

return __call__
Expand Down Expand Up @@ -860,6 +865,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
primary_matcher = builtin_matchers.message_event(
keyword=keyword, constraints=constraints, base_logger=self._base_logger
)
if self._attaching_conversation_kwargs_enabled:
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
middleware.insert(0, MessageListenerMatches(keyword))
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)

Expand Down Expand Up @@ -1356,20 +1363,6 @@ <h2 class="section-title" id="header-classes">Classes</h2>
# It is intended for apps that start lazy listeners from their custom global middleware.
req.context[&#34;listener_runner&#34;] = self.listener_runner

# For AI Agents &amp; Assistants
if is_assistant_event(req.body):
assistant = AssistantUtilities(
payload=to_event(req.body), # type:ignore[arg-type]
context=req.context,
thread_context_store=self._assistant_thread_context_store,
)
req.context[&#34;say&#34;] = assistant.say
req.context[&#34;set_status&#34;] = assistant.set_status
req.context[&#34;set_title&#34;] = assistant.set_title
req.context[&#34;set_suggested_prompts&#34;] = assistant.set_suggested_prompts
req.context[&#34;get_thread_context&#34;] = assistant.get_thread_context
req.context[&#34;save_thread_context&#34;] = assistant.save_thread_context

@staticmethod
def _to_listener_functions(
kwargs: dict,
Expand Down Expand Up @@ -1415,7 +1408,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
CustomListener(
app_name=self.name,
ack_function=functions.pop(0),
lazy_functions=functions, # type:ignore[arg-type]
lazy_functions=functions, # type: ignore[arg-type]
matchers=listener_matchers,
middleware=listener_middleware,
auto_acknowledgement=auto_acknowledgement,
Expand Down Expand Up @@ -2203,10 +2196,13 @@ <h2 id="args">Args</h2>
middleware: A list of lister middleware functions.
Only when all the middleware call `next()` method, the listener function can be invoked.
&#34;&#34;&#34;
middleware = list(middleware) if middleware else []

def __call__(*args, **kwargs):
functions = self._to_listener_functions(kwargs) if kwargs else list(args)
primary_matcher = builtin_matchers.event(event, base_logger=self._base_logger)
if self._attaching_conversation_kwargs_enabled:
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)

return __call__</code></pre>
Expand Down Expand Up @@ -2410,6 +2406,8 @@ <h2 id="args">Args</h2>
primary_matcher = builtin_matchers.message_event(
keyword=keyword, constraints=constraints, base_logger=self._base_logger
)
if self._attaching_conversation_kwargs_enabled:
middleware.insert(0, AttachingConversationKwargs(self._assistant_thread_context_store))
middleware.insert(0, MessageListenerMatches(keyword))
return self._register_listener(list(functions), primary_matcher, matchers, middleware, True)

Expand Down
Loading