diff --git a/docs/english/concepts/acknowledge.md b/docs/english/concepts/acknowledge.md index 7d91e0851..57b346bd3 100644 --- a/docs/english/concepts/acknowledge.md +++ b/docs/english/concepts/acknowledge.md @@ -11,6 +11,9 @@ We recommend calling `ack()` right away before initiating any time-consuming pro ::: Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. + +## Example + ```python # Example of responding to an external_select options request @app.options("menu_selection") diff --git a/docs/english/concepts/adapters.md b/docs/english/concepts/adapters.md index 321dae0ab..ad43a27da 100644 --- a/docs/english/concepts/adapters.md +++ b/docs/english/concepts/adapters.md @@ -8,6 +8,8 @@ To use an adapter, you'll create an app with the framework of your choosing and The full list adapters, as well as configuration and sample usage, can be found within the repository's [`examples`](https://github.com/slackapi/bolt-python/tree/main/examples) +## Example + ```python from slack_bolt import App app = App( diff --git a/docs/english/concepts/app-home.md b/docs/english/concepts/app-home.md index 8b0e2cf11..f4f15337f 100644 --- a/docs/english/concepts/app-home.md +++ b/docs/english/concepts/app-home.md @@ -5,6 +5,9 @@ You can subscribe to the [`app_home_opened`](/reference/events/app_home_opened) event to listen for when users open your App Home. Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. + +## Example + ```python @app.event("app_home_opened") def update_home_tab(client, event, logger): diff --git a/docs/english/concepts/authorization.md b/docs/english/concepts/authorization.md index 242a86b39..f6a258491 100644 --- a/docs/english/concepts/authorization.md +++ b/docs/english/concepts/authorization.md @@ -12,6 +12,8 @@ For a more custom solution, you can set the `authorize` parameter to a function - **`enterprise_id`** and **`team_id`**, which can be found in requests sent to your app. - **`user_id`** only when using `user_token`. +## Example + ```python import os from slack_bolt import App diff --git a/docs/english/concepts/commands.md b/docs/english/concepts/commands.md index 81167fb83..cd772c57b 100644 --- a/docs/english/concepts/commands.md +++ b/docs/english/concepts/commands.md @@ -9,6 +9,9 @@ There are two ways to respond to slash commands. The first way is to use `say()` When setting up commands within your app configuration, you'll append `/slack/events` to your request URL. Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. + +## Example + ```python # The echo command simply echoes on command @app.command("/echo") diff --git a/docs/english/concepts/context.md b/docs/english/concepts/context.md index fb134c896..46684ea28 100644 --- a/docs/english/concepts/context.md +++ b/docs/english/concepts/context.md @@ -4,6 +4,8 @@ All listeners have access to a `context` dictionary, which can be used to enrich `context` is just a dictionary, so you can directly modify it. +## Example + ```python # Listener middleware to fetch tasks from external system using user ID def fetch_tasks(context, event, next): diff --git a/docs/english/concepts/custom-adapters.md b/docs/english/concepts/custom-adapters.md index 62532e7cd..21f7f33e0 100644 --- a/docs/english/concepts/custom-adapters.md +++ b/docs/english/concepts/custom-adapters.md @@ -18,6 +18,8 @@ Your adapter will return [an instance of `BoltResponse`](https://github.com/slac For more in-depth examples of custom adapters, look at the implementations of the [built-in adapters](https://github.com/slackapi/bolt-python/tree/main/slack_bolt/adapter). +## Example + ```python # Necessary imports for Flask from flask import Request, Response, make_response diff --git a/docs/english/concepts/errors.md b/docs/english/concepts/errors.md index ed41c5816..7b40adb7f 100644 --- a/docs/english/concepts/errors.md +++ b/docs/english/concepts/errors.md @@ -4,6 +4,8 @@ If an error occurs in a listener, you can handle it directly using a try/except By default, the global error handler will log all non-handled exceptions to the console. To handle global errors yourself, you can attach a global error handler to your app using the `app.error(fn)` function. +## Example + ```python @app.error def custom_error_handler(error, body, logger): diff --git a/docs/english/concepts/global-middleware.md b/docs/english/concepts/global-middleware.md index dbcdeae99..7b7bdb059 100644 --- a/docs/english/concepts/global-middleware.md +++ b/docs/english/concepts/global-middleware.md @@ -5,6 +5,9 @@ Global middleware is run for all incoming requests, before any listener middlewa Both global and listener middleware must call `next()` to pass control of the execution chain to the next middleware. Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. + +## Example + ```python @app.use def auth_acme(client, context, logger, payload, next): diff --git a/docs/english/concepts/listener-middleware.md b/docs/english/concepts/listener-middleware.md index c8bfc964e..dd020373f 100644 --- a/docs/english/concepts/listener-middleware.md +++ b/docs/english/concepts/listener-middleware.md @@ -6,6 +6,8 @@ If your listener middleware is a quite simple one, you can use a listener matche Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. +## Example + ```python # Listener middleware which filters out messages from a bot def no_bot_messages(message, next): diff --git a/docs/english/concepts/logging.md b/docs/english/concepts/logging.md index 49e275d2d..599431550 100644 --- a/docs/english/concepts/logging.md +++ b/docs/english/concepts/logging.md @@ -4,6 +4,8 @@ By default, Bolt will log information from your app to the output destination. A Outside of a global context, you can also log a single message corresponding to a specific level. Because Bolt uses Python’s [standard logging module](https://docs.python.org/3/library/logging.html), you can use any its features. +## Example + ```python import logging diff --git a/docs/english/concepts/opening-modals.md b/docs/english/concepts/opening-modals.md index 1f053539f..01716f613 100644 --- a/docs/english/concepts/opening-modals.md +++ b/docs/english/concepts/opening-modals.md @@ -8,6 +8,8 @@ Read more about modal composition in the [API documentation](/surfaces/modals#co Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. +## Example + ```python # Listen for a shortcut invocation @app.shortcut("open_modal") diff --git a/docs/english/concepts/select-menu-options.md b/docs/english/concepts/select-menu-options.md index 40d29472c..8e6cbb9fe 100644 --- a/docs/english/concepts/select-menu-options.md +++ b/docs/english/concepts/select-menu-options.md @@ -10,6 +10,9 @@ To respond to options requests, you'll need to call `ack()` with a valid `option Additionally, you may want to apply filtering logic to the returned options based on user input. This can be accomplished by using the `payload` argument to your options listener and checking for the contents of the `value` property within it. Based on the `value` you can return different options. All listeners and middleware handlers in Bolt for Python have access to [many useful arguments](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) - be sure to check them out! Refer to [the module document](https://docs.slack.dev/tools/bolt-python/reference/kwargs_injection/args.html) to learn the available listener arguments. + +## Example + ```python # Example of responding to an external_select options request @app.options("external_action") diff --git a/docs/english/concepts/web-api.md b/docs/english/concepts/web-api.md index 9cf436851..81f7c9b60 100644 --- a/docs/english/concepts/web-api.md +++ b/docs/english/concepts/web-api.md @@ -8,6 +8,8 @@ The token used to initialize Bolt can be found in the `context` object, which is ::: +## Example + ```python @app.message("wake me up") def say_hello(client, message):