diff --git a/docs/README.md b/docs/README.md index c1f79adfb..023d89975 100644 --- a/docs/README.md +++ b/docs/README.md @@ -71,7 +71,6 @@ Then grab the latest version of Node. nvm install node ``` - If you are running this project locally for the first time, you'll need to install the packages with the following command: ``` diff --git a/docs/content/basic/action-listening.md b/docs/content/basic/action-listening.md deleted file mode 100644 index cd677d22d..000000000 --- a/docs/content/basic/action-listening.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Listening to actions -lang: en -slug: /concepts/action-listening ---- - -Your app can listen to user actions, like button clicks, and menu selects, using the `action` method. - -Actions can be filtered on an `action_id` of type `str` or `re.Pattern`. `action_id`s act as unique identifiers for interactive components on the Slack platform. - -You'll notice in all `action()` examples, `ack()` is used. It is required to call the `ack()` function within an action listener to acknowledge that the request was received from Slack. This is discussed in the [acknowledging requests section](/concepts/acknowledge). - -Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. -```python -# Your listener will be called every time a block element with the action_id "approve_button" is triggered -@app.action("approve_button") -def update_message(ack): - ack() - # Update the message to reflect the action -``` - -
- -Listening to actions using a constraint object - - -You can use a constraints object to listen to `block_id`s and `action_id`s (or any combination of them). Constraints in the object can be of type `str` or `re.Pattern`. - -```python -# Your function will only be called when the action_id matches 'select_user' AND the block_id matches 'assign_ticket' -@app.action({ - "block_id": "assign_ticket", - "action_id": "select_user" -}) -def update_message(ack, body, client): - ack() - - if "container" in body and "message_ts" in body["container"]: - client.reactions_add( - name="white_check_mark", - channel=body["channel"]["id"], - timestamp=body["container"]["message_ts"], - ) -``` - -
\ No newline at end of file diff --git a/docs/content/basic/action-respond.md b/docs/content/basic/action-respond.md deleted file mode 100644 index 7153f18bd..000000000 --- a/docs/content/basic/action-respond.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: Responding to actions -lang: en -slug: /concepts/action-respond ---- - -There are two main ways to respond to actions. The first (and most common) way is to use `say()`, which sends a message back to the conversation where the incoming request took place. - -The second way to respond to actions is using `respond()`, which is a utility to use the `response_url` associated with the action. - -Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. -```python -# Your listener will be called every time an interactive component with the action_id “approve_button” is triggered -@app.action("approve_button") -def approve_request(ack, say): - # Acknowledge action request - ack() - say("Request approved 👍") -``` - -
- -Using respond() - - -Since `respond()` is a utility for calling the `response_url`, it behaves in the same way. You can pass [all the message payload properties](https://api.slack.com/reference/messaging/payload) as keyword arguments along with optional properties like `response_type` (which has a value of `"in_channel"` or `"ephemeral"`), `replace_original`, `delete_original`, `unfurl_links`, and `unfurl_media`. With that, your app can send a new message payload that will be published back to the source of the original interaction. - -```python -# Listens to actions triggered with action_id of “user_select” -@app.action("user_select") -def select_user(ack, action, respond): - ack() - respond(f"You selected <@{action['selected_user']}>") -``` - -
\ No newline at end of file diff --git a/docs/content/basic/acknowledge.md b/docs/content/concepts/acknowledge.md similarity index 100% rename from docs/content/basic/acknowledge.md rename to docs/content/concepts/acknowledge.md diff --git a/docs/content/concepts/actions.md b/docs/content/concepts/actions.md new file mode 100644 index 000000000..b2ab27920 --- /dev/null +++ b/docs/content/concepts/actions.md @@ -0,0 +1,73 @@ +--- +title: Listening & responding to actions +lang: en +slug: /concepts/actions +--- + +Your app can listen and respond to user actions, like button clicks, and menu selects, using the `action` method. + +## Listening to actions + +Actions can be filtered on an `action_id` parameter of type `str` or `re.Pattern`. The `action_id` parameter acts as a unique identifier for interactive components on the Slack platform. + +You'll notice in all `action()` examples, `ack()` is used. It is required to call the `ack()` function within an action listener to acknowledge that the request was received from Slack. This is discussed in the [acknowledging requests guide](/concepts/acknowledge). + +Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. + +```python +# Your listener will be called every time a block element with the action_id "approve_button" is triggered +@app.action("approve_button") +def update_message(ack): + ack() + # Update the message to reflect the action +``` + +### Listening to actions using a constraint object + +You can use a constraints object to listen to `block_id`s and `action_id`s (or any combination of them). Constraints in the object can be of type `str` or `re.Pattern`. + +```python +# Your function will only be called when the action_id matches 'select_user' AND the block_id matches 'assign_ticket' +@app.action({ + "block_id": "assign_ticket", + "action_id": "select_user" +}) +def update_message(ack, body, client): + ack() + + if "container" in body and "message_ts" in body["container"]: + client.reactions_add( + name="white_check_mark", + channel=body["channel"]["id"], + timestamp=body["container"]["message_ts"], + ) +``` + +## Responding to actions + +There are two main ways to respond to actions. The first (and most common) way is to use `say()`, which sends a message back to the conversation where the incoming request took place. + +The second way to respond to actions is using `respond()`, which is a utility to use the `response_url` associated with the action. + +Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. + +```python +# Your listener will be called every time an interactive component with the action_id “approve_button” is triggered +@app.action("approve_button") +def approve_request(ack, say): + # Acknowledge action request + ack() + say("Request approved 👍") +``` + +### Using `respond()` method + +Since `respond()` is a utility for calling the `response_url`, it behaves in the same way. You can pass [all the message payload properties](https://api.slack.com/reference/messaging/payload) as keyword arguments along with optional properties like `response_type` (which has a value of `"in_channel"` or `"ephemeral"`), `replace_original`, `delete_original`, `unfurl_links`, and `unfurl_media`. With that, your app can send a new message payload that will be published back to the source of the original interaction. + +```python +# Listens to actions triggered with action_id of “user_select” +@app.action("user_select") +def select_user(ack, action, respond): + ack() + respond(f"You selected <@{action['selected_user']}>") +``` \ No newline at end of file diff --git a/docs/content/advanced/adapters.md b/docs/content/concepts/adapters.md similarity index 59% rename from docs/content/advanced/adapters.md rename to docs/content/concepts/adapters.md index e8beb9c97..ad4303b15 100644 --- a/docs/content/advanced/adapters.md +++ b/docs/content/concepts/adapters.md @@ -4,15 +4,13 @@ lang: en slug: /concepts/adapters --- +Adapters are responsible for handling and parsing incoming requests from Slack to conform to [`BoltRequest`](https://github.com/slackapi/bolt-python/blob/main/slack_bolt/request/request.py), then dispatching those requests to your Bolt app. -Adapters are responsible for handling and parsing incoming requests from Slack to conform to `BoltRequest`, then dispatching those requests to your Bolt app. - -By default, Bolt will use the built-in `HTTPServer` adapter. While this is okay for local development, it is not recommended for production. Bolt for Python includes a collection of built-in adapters that can be imported and used with your app. The built-in adapters support a variety of popular Python frameworks including Flask, Django, and Starlette among others. Adapters support the use of any production-ready web server of your choice. +By default, Bolt will use the built-in [`HTTPServer`](https://docs.python.org/3/library/http.server.html) adapter. While this is okay for local development, **it is not recommended for production**. Bolt for Python includes a collection of built-in adapters that can be imported and used with your app. The built-in adapters support a variety of popular Python frameworks including Flask, Django, and Starlette among others. Adapters support the use of any production-ready web server of your choice. To use an adapter, you'll create an app with the framework of your choosing and import its corresponding adapter. Then you'll initialize the adapter instance and call its function that handles and parses incoming requests. -The full list adapters, as well as configuration and sample usage, can be found within the repository's `examples` folder. - +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) ```python from slack_bolt import App diff --git a/docs/content/basic/app-home.md b/docs/content/concepts/app-home.md similarity index 69% rename from docs/content/basic/app-home.md rename to docs/content/concepts/app-home.md index a7a6a1f02..887279a5d 100644 --- a/docs/content/basic/app-home.md +++ b/docs/content/concepts/app-home.md @@ -4,9 +4,9 @@ lang: en slug: /concepts/app-home --- -Home tabs are customizable surfaces accessible via the sidebar and search that allow apps to display views on a per-user basis. After enabling App Home within your app configuration, home tabs can be published and updated by passing a `user_id` and view payload to the `views.publish` method. +[Home tabs](https://api.slack.com/surfaces/tabs/using) are customizable surfaces accessible via the sidebar and search that allow apps to display views on a per-user basis. After enabling App Home within your app configuration, home tabs can be published and updated by passing a `user_id` and [view payload](https://api.slack.com/reference/block-kit/views) to the [`views.publish`](https://api.slack.com/methods/views.publish) method. -You can subscribe to the `app_home_opened` event to listen for when users open your App Home. +You can subscribe to the [`app_home_opened`](https://api.slack.com/events/app_home_opened) event to listen for when users open your App Home. Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. ```python diff --git a/docs/content/basic/assistant.md b/docs/content/concepts/assistant.md similarity index 99% rename from docs/content/basic/assistant.md rename to docs/content/concepts/assistant.md index 07da78424..469bba966 100644 --- a/docs/content/basic/assistant.md +++ b/docs/content/concepts/assistant.md @@ -277,7 +277,6 @@ def respond_to_user_messages(logger: logging.Logger, set_status: SetStatus, say: logger.exception(f"Failed to respond to an inquiry: {e}") say(f":warning: Sorry, something went wrong during processing your request (error: {e})") - # Enable this assistant middleware in your Bolt app app.use(assistant) ``` diff --git a/docs/content/advanced/async.md b/docs/content/concepts/async.md similarity index 83% rename from docs/content/advanced/async.md rename to docs/content/concepts/async.md index 9544ad810..197377f93 100644 --- a/docs/content/advanced/async.md +++ b/docs/content/concepts/async.md @@ -4,11 +4,9 @@ lang: en slug: /concepts/async --- +To use the async version of Bolt, you can import and initialize an `AsyncApp` instance (rather than `App`). `AsyncApp` relies on [AIOHTTP](https://docs.aiohttp.org) to make API requests, which means you'll need to install `aiohttp` (by adding to `requirements.txt` or running `pip install aiohttp`). -To use the async version of Bolt, you can import and initialize an `AsyncApp` instance (rather than `App`). `AsyncApp` relies on AIOHTTP to make API requests, which means you'll need to install `aiohttp` (by adding to `requirements.txt` or running `pip install aiohttp`). - -Sample async projects can be found within the repository's `examples` folder. - +Sample async projects can be found within the repository's [examples](https://github.com/slackapi/bolt-python/tree/main/examples) folder. ```python # Requirement: install aiohttp @@ -28,12 +26,7 @@ if __name__ == "__main__": app.start(3000) ``` -
- -Using other frameworks - - - +## Using other frameworks Internally `AsyncApp#start()` implements a [`AIOHTTP`](https://docs.aiohttp.org/) web server. If you prefer, you can use a framework other than `AIOHTTP` to handle incoming requests. @@ -48,7 +41,6 @@ pip install slack_bolt sanic uvicorn uvicorn async_app:api --reload --port 3000 --log-level debug ``` - ```python from slack_bolt.async_app import AsyncApp app = AsyncApp() @@ -76,5 +68,4 @@ async def endpoint(req: Request): if __name__ == "__main__": api.run(host="0.0.0.0", port=int(os.environ.get("PORT", 3000))) -``` -
+``` \ No newline at end of file diff --git a/docs/content/basic/authenticating-oauth.md b/docs/content/concepts/authenticating-oauth.md similarity index 98% rename from docs/content/basic/authenticating-oauth.md rename to docs/content/concepts/authenticating-oauth.md index 321803497..734a727b2 100644 --- a/docs/content/basic/authenticating-oauth.md +++ b/docs/content/concepts/authenticating-oauth.md @@ -35,10 +35,7 @@ app = App( ) ``` -
- -Customizing OAuth defaults - +## Customizing OAuth defaults You can override the default OAuth using `oauth_settings`, which can be passed in during the initialization of App. You can override the following: @@ -90,6 +87,4 @@ app = App( callback_options=callback_options, ), ) -``` - -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/advanced/authorization.md b/docs/content/concepts/authorization.md similarity index 99% rename from docs/content/advanced/authorization.md rename to docs/content/concepts/authorization.md index 7a67d79ca..4c293b5c2 100644 --- a/docs/content/advanced/authorization.md +++ b/docs/content/concepts/authorization.md @@ -4,7 +4,6 @@ lang: en slug: /concepts/authorization --- - Authorization is the process of determining which Slack credentials should be available while processing an incoming Slack request. Apps installed on a single workspace can simply pass their bot token into the `App` constructor using the `token` parameter. However, if your app will be installed on multiple workspaces, you have two options. The easier option is to use the built-in OAuth support. This will handle setting up OAuth routes and verifying state. Read the section on [authenticating with OAuth](/concepts/authenticating-oauth) for details. @@ -17,7 +16,6 @@ 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`. - ```python import os from slack_bolt import App diff --git a/docs/content/basic/commands.md b/docs/content/concepts/commands.md similarity index 100% rename from docs/content/basic/commands.md rename to docs/content/concepts/commands.md diff --git a/docs/content/advanced/context.md b/docs/content/concepts/context.md similarity index 99% rename from docs/content/advanced/context.md rename to docs/content/concepts/context.md index 34d7819f7..cf7fa45f1 100644 --- a/docs/content/advanced/context.md +++ b/docs/content/concepts/context.md @@ -4,12 +4,10 @@ lang: en slug: /concepts/context --- - All listeners have access to a `context` dictionary, which can be used to enrich requests with additional information. Bolt automatically attaches information that is included in the incoming request, like `user_id`, `team_id`, `channel_id`, and `enterprise_id`. `context` is just a dictionary, so you can directly modify it. - ```python # Listener middleware to fetch tasks from external system using user ID def fetch_tasks(context, event, next): diff --git a/docs/content/advanced/custom-adapters.md b/docs/content/concepts/custom-adapters.md similarity index 99% rename from docs/content/advanced/custom-adapters.md rename to docs/content/concepts/custom-adapters.md index 313173750..55c73130d 100644 --- a/docs/content/advanced/custom-adapters.md +++ b/docs/content/concepts/custom-adapters.md @@ -4,7 +4,6 @@ lang: en slug: /concepts/custom-adapters --- - [Adapters](/concepts/adapters) are flexible and can be adjusted based on the framework you prefer. There are two necessary components of adapters: - `__init__(app: App)`: Constructor that accepts and stores an instance of the Bolt `App`. @@ -23,7 +22,6 @@ 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). - ```python # Necessary imports for Flask from flask import Request, Response, make_response diff --git a/docs/content/basic/custom-steps.md b/docs/content/concepts/custom-steps.md similarity index 99% rename from docs/content/basic/custom-steps.md rename to docs/content/concepts/custom-steps.md index 1eedf9f5d..f91fac33c 100644 --- a/docs/content/basic/custom-steps.md +++ b/docs/content/concepts/custom-steps.md @@ -1,5 +1,6 @@ --- title: Listening and responding to custom steps +sidebar_label: Custom steps lang: en slug: /concepts/custom-steps --- diff --git a/docs/content/advanced/errors.md b/docs/content/concepts/errors.md similarity index 99% rename from docs/content/advanced/errors.md rename to docs/content/concepts/errors.md index 59601f47b..d0e5cccad 100644 --- a/docs/content/advanced/errors.md +++ b/docs/content/concepts/errors.md @@ -4,12 +4,10 @@ lang: en slug: /concepts/errors --- - If an error occurs in a listener, you can handle it directly using a try/except block. Errors associated with your app will be of type `BoltError`. Errors associated with calling Slack APIs will be of type `SlackApiError`. 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. - ```python @app.error def custom_error_handler(error, body, logger): diff --git a/docs/content/basic/event-listening.md b/docs/content/concepts/event-listening.md similarity index 95% rename from docs/content/basic/event-listening.md rename to docs/content/concepts/event-listening.md index 95c6e84ea..79317b07a 100644 --- a/docs/content/basic/event-listening.md +++ b/docs/content/concepts/event-listening.md @@ -18,11 +18,8 @@ def ask_for_introduction(event, say): text = f"Welcome to the team, <@{user_id}>! 🎉 You can introduce yourself in this channel." say(text=text, channel=welcome_channel_id) ``` -
- - Filtering on message subtypes - +## Filtering on message subtypes The `message()` listener is equivalent to `event("message")`. @@ -38,5 +35,4 @@ You can explicitly filter for events without a subtype by explicitly setting `No def log_message_change(logger, event): user, text = event["user"], event["text"] logger.info(f"The user {user} changed the message to {text}") -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/advanced/global-middleware.md b/docs/content/concepts/global-middleware.md similarity index 99% rename from docs/content/advanced/global-middleware.md rename to docs/content/concepts/global-middleware.md index 61aa97066..ec748c000 100644 --- a/docs/content/advanced/global-middleware.md +++ b/docs/content/concepts/global-middleware.md @@ -4,13 +4,10 @@ lang: en slug: /concepts/global-middleware --- - Global middleware is run for all incoming requests, before any listener middleware. You can add any number of global middleware to your app by passing middleware functions to `app.use()`. Middleware functions are called with the same arguments as listeners, with an additional `next()` function. 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://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. ```python @app.use diff --git a/docs/content/advanced/lazy-listeners.md b/docs/content/concepts/lazy-listeners.md similarity index 95% rename from docs/content/advanced/lazy-listeners.md rename to docs/content/concepts/lazy-listeners.md index e179c6afc..d72c2f9c0 100644 --- a/docs/content/advanced/lazy-listeners.md +++ b/docs/content/concepts/lazy-listeners.md @@ -4,7 +4,6 @@ lang: en slug: /concepts/lazy-listeners --- - Lazy Listeners are a feature which make it easier to deploy Slack apps to FaaS (Function-as-a-Service) environments. Please note that this feature is only available in Bolt for Python, and we are not planning to add the same to other Bolt frameworks. Typically when handling actions, commands, shortcuts, options and view submissions, you must acknowledge the request from Slack by calling `ack()` within 3 seconds. Calling `ack()` results in sending an HTTP 200 OK response to Slack, letting Slack know that you're handling the response. We normally encourage you to do this as the very first step in your handler function. @@ -15,7 +14,6 @@ To allow you to still run more time-consuming processes as part of your handler, * `ack: Callable`: Responsible for calling `ack()` within 3 seconds * `lazy: List[Callable]`: Responsible for handling time-consuming processes related to the request. The lazy function does not have access to `ack()`. - ```python def respond_to_slack_within_3_seconds(body, ack): text = body.get("text") @@ -37,13 +35,9 @@ app.command("/start-process")( ) ``` -
- -Example with AWS Lambda - - +## Example with AWS Lambda -This example deploys the code to [AWS Lambda](https://aws.amazon.com/lambda/). There are more examples within the [`examples` folder](https://github.com/slackapi/bolt-python/tree/main/examples/aws_lambda). +This example deploys the code to [AWS Lambda](https://aws.amazon.com/lambda/). There are more examples within the [`examples`](https://github.com/slackapi/bolt-python/tree/main/examples/aws_lambda) folder. ```bash pip install slack_bolt @@ -61,7 +55,6 @@ echo 'slack_bolt' > requirements.txt lambda deploy --config-file config.yaml --requirements requirements.txt ``` - ```python from slack_bolt import App from slack_bolt.adapter.aws_lambda import SlackRequestHandler @@ -108,5 +101,4 @@ Please note that the following IAM permissions would be required for running thi } ] } -``` -
+``` \ No newline at end of file diff --git a/docs/content/advanced/listener-middleware.md b/docs/content/concepts/listener-middleware.md similarity index 100% rename from docs/content/advanced/listener-middleware.md rename to docs/content/concepts/listener-middleware.md diff --git a/docs/content/advanced/logging.md b/docs/content/concepts/logging.md similarity index 99% rename from docs/content/advanced/logging.md rename to docs/content/concepts/logging.md index 900484b7a..5f82d168a 100644 --- a/docs/content/advanced/logging.md +++ b/docs/content/concepts/logging.md @@ -4,12 +4,10 @@ lang: en slug: /concepts/logging --- - By default, Bolt will log information from your app to the output destination. After you've imported the `logging` module, you can customize the root log level by passing the `level` parameter to `basicConfig()`. The available log levels in order of least to most severe are `debug`, `info`, `warning`, `error`, and `critical`. 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. - ```python import logging diff --git a/docs/content/basic/message-listening.md b/docs/content/concepts/message-listening.md similarity index 93% rename from docs/content/basic/message-listening.md rename to docs/content/concepts/message-listening.md index 0243b1537..3527dc226 100644 --- a/docs/content/basic/message-listening.md +++ b/docs/content/concepts/message-listening.md @@ -22,10 +22,7 @@ def say_hello(message, say): say(f"Hi there, <@{user}>!") ``` -
- -Using a regular expression pattern - +## Using a regular expression pattern The `re.compile()` method can be used instead of a string for more granular matching. @@ -37,6 +34,4 @@ def say_hello_regex(say, context): # regular expression matches are inside of context.matches greeting = context['matches'][0] say(f"{greeting}, how are you?") -``` - -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/basic/message-sending.md b/docs/content/concepts/message-sending.md similarity index 96% rename from docs/content/basic/message-sending.md rename to docs/content/concepts/message-sending.md index d7b5d2da9..b44f8848f 100644 --- a/docs/content/basic/message-sending.md +++ b/docs/content/concepts/message-sending.md @@ -16,10 +16,7 @@ def ask_who(message, say): say("_Who's there?_") ``` -
- -Sending a message with blocks - +## Sending a message with blocks `say()` accepts more complex message payloads to make it easy to add functionality and structure to your messages. @@ -45,6 +42,4 @@ def show_datepicker(event, say): blocks=blocks, text="Pick a date for me to remind you" ) -``` - -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/basic/opening-modals.md b/docs/content/concepts/opening-modals.md similarity index 77% rename from docs/content/basic/opening-modals.md rename to docs/content/concepts/opening-modals.md index 9049a5bdb..a686eec63 100644 --- a/docs/content/basic/opening-modals.md +++ b/docs/content/concepts/opening-modals.md @@ -4,9 +4,9 @@ lang: en slug: /concepts/opening-modals --- -[Modals](https://api.slack.com/block-kit/surfaces/modal) are focused surfaces that allow you to collect user data and display dynamic information. You can open a modal by passing a valid `trigger_id` and a [view payload](https://api.slack.com/reference/block-kit/views) to the built-in client's [`views.open`](https://api.slack.com/methods/views.open) method. +[Modals](https://api.slack.com/block-kit/surfaces/modals) are focused surfaces that allow you to collect user data and display dynamic information. You can open a modal by passing a valid `trigger_id` and a [view payload](https://api.slack.com/reference/block-kit/views) to the built-in client's [`views.open`](https://api.slack.com/methods/views.open) method. -Your app receives `trigger_id`s in payloads sent to your Request URL that are triggered by user invocations, like a shortcut, button press, or interaction with a select menu. +Your app receives `trigger_id` parameters in payloads sent to your Request URL triggered user invocation like a slash command, button press, or interaction with a select menu. Read more about modal composition in the [API documentation](https://api.slack.com/surfaces/modals/using#composing_views). diff --git a/docs/content/basic/options.md b/docs/content/concepts/select-menu-options.md similarity index 97% rename from docs/content/basic/options.md rename to docs/content/concepts/select-menu-options.md index e7c1e1243..835ae15c7 100644 --- a/docs/content/basic/options.md +++ b/docs/content/concepts/select-menu-options.md @@ -1,5 +1,5 @@ --- -title: Listening and responding to options +title: Listening & responding to select menu options lang: en slug: /concepts/options --- diff --git a/docs/content/basic/shortcuts.md b/docs/content/concepts/shortcuts.md similarity index 94% rename from docs/content/basic/shortcuts.md rename to docs/content/concepts/shortcuts.md index 6f469c20f..d9f02c2a1 100644 --- a/docs/content/basic/shortcuts.md +++ b/docs/content/concepts/shortcuts.md @@ -53,11 +53,9 @@ def open_modal(ack, shortcut, client): ) ``` -
- - Listening to shortcuts using a constraint object - - You can use a constraints object to listen to `callback_id`s, and `type`s. Constraints in the object can be of type `str` or `re.Pattern`. +## Listening to shortcuts using a constraint object + +You can use a constraints object to listen to `callback_id`s, and `type`s. Constraints in the object can be of type `str` or `re.Pattern`. ```python # Your listener will only be called when the callback_id matches 'open_modal' AND the type matches 'message_action' @@ -92,5 +90,4 @@ def open_modal(ack, shortcut, client): ] } ) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/basic/socket-mode.md b/docs/content/concepts/socket-mode.md similarity index 97% rename from docs/content/basic/socket-mode.md rename to docs/content/concepts/socket-mode.md index 61be345de..72a2b7982 100644 --- a/docs/content/basic/socket-mode.md +++ b/docs/content/concepts/socket-mode.md @@ -17,7 +17,6 @@ While we recommend using [the built-in Socket Mode adapter](https://github.com/s |[aiohttp](https://pypi.org/project/aiohttp/) (asyncio-based)|[slack_bolt.adapter.socket_mode.aiohttp](https://github.com/slackapi/bolt-python/tree/main/slack_bolt/adapter/socket_mode/aiohttp)| |[websockets](https://pypi.org/project/websockets/) (asyncio-based)|[slack_bolt.adapter.socket_mode.websockets](https://github.com/slackapi/bolt-python/tree/main/slack_bolt/adapter/socket_mode/websockets)| - ```python import os from slack_bolt import App @@ -35,10 +34,7 @@ if __name__ == "__main__": handler.start() ``` -
- -Using Async (asyncio) - +## Using Async (asyncio) To use the asyncio-based adapters such as aiohttp, your whole app needs to be compatible with asyncio's async/await programming model. `AsyncSocketModeHandler` is available for running `AsyncApp` and its async middleware and listeners. @@ -60,5 +56,4 @@ async def main(): if __name__ == "__main__": import asyncio asyncio.run(main()) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/content/concepts/steps-from-apps.md b/docs/content/concepts/steps-from-apps.md new file mode 100644 index 000000000..84315143b --- /dev/null +++ b/docs/content/concepts/steps-from-apps.md @@ -0,0 +1,205 @@ +--- +title: Steps from apps +lang: en +slug: /legacy/steps-from-apps +--- + +:::danger + +Steps from apps are a deprecated feature. + +Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as [custom steps for Bolt](https://api.slack.com/automation/functions/custom-bolt), + +Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. + +::: + +Steps from apps allow your app to create and process steps that users can add using [Workflow Builder](https://api.slack.com/workflows). + +Steps from apps are made up of three distinct user events: + +- Adding or editing the step in a Workflow +- Saving or updating the step's configuration +- The end user's execution of the step + +All three events must be handled for a step from app to function. + +Read more about steps from apps in the [API documentation](https://api.slack.com/workflows/steps). + +## Creating steps from apps + +To create a step from app, Bolt provides the `WorkflowStep` class. + +When instantiating a new `WorkflowStep`, pass in the step's `callback_id` and a configuration object. + +The configuration object contains three keys: `edit`, `save`, and `execute`. Each of these keys must be a single callback or a list of callbacks. All callbacks have access to a `step` object that contains information about the step from app event. + +After instantiating a `WorkflowStep`, you can pass it into `app.step()`. Behind the scenes, your app will listen and respond to the step’s events using the callbacks provided in the configuration object. + +Alternatively, steps from apps can also be created using the `WorkflowStepBuilder` class alongside a decorator pattern. For more information, including an example of this approach, [refer to the documentation](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/step.html#slack_bolt.workflows.step.step.WorkflowStepBuilder). + +Refer to the module documents ([common](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) / [step-specific](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/utilities/index.html)) to learn the available arguments. + +```python +import os +from slack_bolt import App +from slack_bolt.workflows.step import WorkflowStep + +# Initiate the Bolt app as you normally would +app = App( + token=os.environ.get("SLACK_BOT_TOKEN"), + signing_secret=os.environ.get("SLACK_SIGNING_SECRET") +) + +def edit(ack, step, configure): + pass + +def save(ack, view, update): + pass + +def execute(step, complete, fail): + pass + +# Create a new WorkflowStep instance +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) + +# Pass Step to set up listeners +app.step(ws) +``` + +## Adding or editing steps from apps + +When a builder adds (or later edits) your step in their workflow, your app will receive a [`workflow_step_edit` event](https://api.slack.com/reference/workflows/workflow_step_edit). The `edit` callback in your `WorkflowStep` configuration will be run when this event is received. + +Whether a builder is adding or editing a step, you need to send them a [step from app configuration modal](https://api.slack.com/reference/workflows/configuration-view). This modal is where step-specific settings are chosen, and it has more restrictions than typical modals—most notably, it cannot include `title`, `submit`, or `close` properties. By default, the configuration modal's `callback_id` will be the same as the step from app. + +Within the `edit` callback, the `configure()` utility can be used to easily open your step's configuration modal by passing in the view's blocks with the corresponding `blocks` argument. To disable saving the configuration before certain conditions are met, you can also pass in `submit_disabled` with a value of `True`. + +To learn more about opening configuration modals, [read the documentation](https://api.slack.com/workflows/steps#handle_config_view). + +Refer to the module documents ([common](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) / [step-specific](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/utilities/index.html)) to learn the available arguments. + +```python +def edit(ack, step, configure): + ack() + + blocks = [ + { + "type": "input", + "block_id": "task_name_input", + "element": { + "type": "plain_text_input", + "action_id": "name", + "placeholder": {"type": "plain_text", "text": "Add a task name"}, + }, + "label": {"type": "plain_text", "text": "Task name"}, + }, + { + "type": "input", + "block_id": "task_description_input", + "element": { + "type": "plain_text_input", + "action_id": "description", + "placeholder": {"type": "plain_text", "text": "Add a task description"}, + }, + "label": {"type": "plain_text", "text": "Task description"}, + }, + ] + configure(blocks=blocks) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` + +## Saving step configurations + +After the configuration modal is opened, your app will listen for the `view_submission` event. The `save` callback in your `WorkflowStep` configuration will be run when this event is received. + +Within the `save` callback, the `update()` method can be used to save the builder's step configuration by passing in the following arguments: + +- `inputs` is a dictionary representing the data your app expects to receive from the user upon step execution. +- `outputs` is a list of objects containing data that your app will provide upon the step's completion. Outputs can then be used in subsequent steps of the workflow. +- `step_name` overrides the default Step name +- `step_image_url` overrides the default Step image + +To learn more about how to structure these parameters, [read the documentation](https://api.slack.com/reference/workflows/workflow_step). + +Refer to the module documents ([common](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) / [step-specific](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/utilities/index.html)) to learn the available arguments. + +```python +def save(ack, view, update): + ack() + + values = view["state"]["values"] + task_name = values["task_name_input"]["name"] + task_description = values["task_description_input"]["description"] + + inputs = { + "task_name": {"value": task_name["value"]}, + "task_description": {"value": task_description["value"]} + } + outputs = [ + { + "type": "text", + "name": "task_name", + "label": "Task name", + }, + { + "type": "text", + "name": "task_description", + "label": "Task description", + } + ] + update(inputs=inputs, outputs=outputs) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` + +## Executing steps from app + +When your step from app is executed by an end user, your app will receive a [`workflow_step_execute` event](https://api.slack.com/events/workflow_step_execute). The `execute` callback in your `WorkflowStep` configuration will be run when this event is received. + +Using the `inputs` from the `save` callback, this is where you can make third-party API calls, save information to a database, update the user's Home tab, or decide the outputs that will be available to subsequent steps from apps by mapping values to the `outputs` object. + +Within the `execute` callback, your app must either call `complete()` to indicate that the step's execution was successful, or `fail()` to indicate that the step's execution failed. + +Refer to the module documents ([common](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) / [step-specific](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/utilities/index.html)) to learn the available arguments. + +```python +def execute(step, complete, fail): + inputs = step["inputs"] + # if everything was successful + outputs = { + "task_name": inputs["task_name"]["value"], + "task_description": inputs["task_description"]["value"], + } + complete(outputs=outputs) + + # if something went wrong + error = {"message": "Just testing step failure!"} + fail(error=error) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` diff --git a/docs/content/advanced/token-rotation.md b/docs/content/concepts/token-rotation.md similarity index 92% rename from docs/content/advanced/token-rotation.md rename to docs/content/concepts/token-rotation.md index 1f278c3aa..ca690dd28 100644 --- a/docs/content/advanced/token-rotation.md +++ b/docs/content/concepts/token-rotation.md @@ -4,12 +4,10 @@ lang: en slug: /concepts/token-rotation --- - Supported in Bolt for Python as of [v1.7.0](https://github.com/slackapi/bolt-python/releases/tag/v1.7.0), token rotation provides an extra layer of security for your access tokens and is defined by the [OAuth V2 RFC](https://datatracker.ietf.org/doc/html/rfc6749#section-10.4). Instead of an access token representing an existing installation of your Slack app indefinitely, with token rotation enabled, access tokens expire. A refresh token acts as a long-lived way to refresh your access tokens. Bolt for Python supports and will handle token rotation automatically so long as the [built-in OAuth](/concepts/authenticating-oauth) functionality is used. -For more information about token rotation, please see the [documentation](https://api.slack.com/authentication/rotation). - +For more information about token rotation, please see the [documentation](https://api.slack.com/authentication/rotation). \ No newline at end of file diff --git a/docs/content/basic/updating-pushing-views.md b/docs/content/concepts/updating-pushing-views.md similarity index 66% rename from docs/content/basic/updating-pushing-views.md rename to docs/content/concepts/updating-pushing-views.md index 8cc45d49a..d7a9e3a3e 100644 --- a/docs/content/basic/updating-pushing-views.md +++ b/docs/content/concepts/updating-pushing-views.md @@ -4,17 +4,17 @@ lang: en slug: /concepts/updating-pushing-views --- -Modals contain a stack of views. When you call `views_open`, you add the root view to the modal. After the initial call, you can dynamically update a view by calling `views_update`, or stack a new view on top of the root view by calling `views_push`. +Modals contain a stack of views. When you call [`views_open`](https://api.slack.com/methods/views.open), you add the root view to the modal. After the initial call, you can dynamically update a view by calling [`views_update`](https://api.slack.com/methods/views.update), or stack a new view on top of the root view by calling [`views_push`](https://api.slack.com/methods/views.push) -**`views_update`** +## The `views_update` method To update a view, you can use the built-in client to call `views_update` with the `view_id` that was generated when you opened the view, and a new `view` including the updated `blocks` list. If you're updating the view when a user interacts with an element inside of an existing view, the `view_id` will be available in the `body` of the request. -**`views_push`** +## The `views_push` method -To push a new view onto the view stack, you can use the built-in client to call `views_push` with a valid `trigger_id` a new view payload. The arguments for `views_push` is the same as opening modals. After you open a modal, you may only push two additional views onto the view stack. +To push a new view onto the view stack, you can use the built-in client to call `views_push` with a valid `trigger_id` a new [view payload](https://api.slack.com/reference/block-kit/views). The arguments for `views_push` is the same as [opening modals](/concepts/creating-models). After you open a modal, you may only push two additional views onto the view stack. -Learn more about updating and pushing views in our API documentation. +Learn more about updating and pushing views in our [API documentation](https://api.slack.com/surfaces/modals/using#modifying) Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. ```python diff --git a/docs/content/basic/view_submissions.md b/docs/content/concepts/view-submissions.md similarity index 84% rename from docs/content/basic/view_submissions.md rename to docs/content/concepts/view-submissions.md index b1c3e7cef..a22911e71 100644 --- a/docs/content/basic/view_submissions.md +++ b/docs/content/concepts/view-submissions.md @@ -4,9 +4,7 @@ lang: en slug: /concepts/view_submissions --- - - -If a view payload contains any input blocks, you must listen to `view_submission` requests to receive their values. To listen to `view_submission` requests, you can use the built-in `view()` method. `view()` requires a `callback_id` of type `str` or `re.Pattern`. +If a [view payload](https://api.slack.com/reference/block-kit/views) contains any input blocks, you must listen to `view_submission` requests to receive their values. To listen to `view_submission` requests, you can use the built-in `view()` method. `view()` requires a `callback_id` of type `str` or `re.Pattern`. You can access the value of the `input` blocks by accessing the `state` object. `state` contains a `values` object that uses the `block_id` and unique `action_id` to store the input values. @@ -26,7 +24,8 @@ def handle_submission(ack, body): ack(response_action="update", view=build_new_view(body)) ``` Similarly, there are options for [displaying errors](https://api.slack.com/surfaces/modals/using#displaying_errors) in response to view submissions. -Read more about view submissions in our API documentation. + +Read more about view submissions in our [API documentation](https://api.slack.com/surfaces/modals/using#handling_submissions) --- @@ -34,7 +33,7 @@ Read more about view submissions in our API documentation for more information about view_closed. +See the [API documentation](https://api.slack.com/surfaces/modals/using#modal_cancellations) for more information about `view_closed`. ```python @@ -63,9 +62,6 @@ def handle_view_closed(ack, body, logger): logger.info(body) ``` - - - Refer to [the module document](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html) to learn the available listener arguments. ```python # Handle a view_submission request diff --git a/docs/content/basic/web-api.md b/docs/content/concepts/web-api.md similarity index 100% rename from docs/content/basic/web-api.md rename to docs/content/concepts/web-api.md diff --git a/docs/content/steps/adding-editing-steps.md b/docs/content/steps/adding-editing-steps.md deleted file mode 100644 index 99ca6d587..000000000 --- a/docs/content/steps/adding-editing-steps.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Adding or editing steps from apps -lang: en -slug: /concepts/adding-editing-steps ---- - -:::danger - -Steps from apps are a deprecated feature. - -Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as custom steps for Bolt. - -Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. - -::: - -When a builder adds (or later edits) your step in their workflow, your app will receive a [`workflow_step_edit` event](https://api.slack.com/reference/workflows/workflow_step_edit). The `edit` callback in your `WorkflowStep` configuration will be run when this event is received. - -Whether a builder is adding or editing a step, you need to send them a [step from app configuration modal](https://api.slack.com/reference/workflows/configuration-view). This modal is where step-specific settings are chosen, and it has more restrictions than typical modals—most notably, it cannot include `title`, `submit`, or `close` properties. By default, the configuration modal's `callback_id` will be the same as the step from app. - -Within the `edit` callback, the `configure()` utility can be used to easily open your step's configuration modal by passing in the view's blocks with the corresponding `blocks` argument. To disable saving the configuration before certain conditions are met, you can also pass in `submit_disabled` with a value of `True`. - -To learn more about opening configuration modals, [read the documentation](https://api.slack.com/workflows/steps#handle_config_view). - -Refer to the module documents (common / step-specific) to learn the available arguments. - -```python -def edit(ack, step, configure): - ack() - - blocks = [ - { - "type": "input", - "block_id": "task_name_input", - "element": { - "type": "plain_text_input", - "action_id": "name", - "placeholder": {"type": "plain_text", "text": "Add a task name"}, - }, - "label": {"type": "plain_text", "text": "Task name"}, - }, - { - "type": "input", - "block_id": "task_description_input", - "element": { - "type": "plain_text_input", - "action_id": "description", - "placeholder": {"type": "plain_text", "text": "Add a task description"}, - }, - "label": {"type": "plain_text", "text": "Task description"}, - }, - ] - configure(blocks=blocks) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` diff --git a/docs/content/steps/creating-steps.md b/docs/content/steps/creating-steps.md deleted file mode 100644 index 6728a77e1..000000000 --- a/docs/content/steps/creating-steps.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: Creating steps from apps -lang: en -slug: /concepts/creating-steps ---- - -:::danger - -Steps from apps are a deprecated feature. - -Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as custom steps for Bolt. - -Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. - -::: - -To create a step from app, Bolt provides the `WorkflowStep` class. - -When instantiating a new `WorkflowStep`, pass in the step's `callback_id` and a configuration object. - -The configuration object contains three keys: `edit`, `save`, and `execute`. Each of these keys must be a single callback or a list of callbacks. All callbacks have access to a `step` object that contains information about the step from app event. - -After instantiating a `WorkflowStep`, you can pass it into `app.step()`. Behind the scenes, your app will listen and respond to the step’s events using the callbacks provided in the configuration object. - -Alternatively, steps from apps can also be created using the `WorkflowStepBuilder` class alongside a decorator pattern. For more information, including an example of this approach, [refer to the documentation](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/step.html#slack_bolt.workflows.step.step.WorkflowStepBuilder). - -Refer to the module documents (common / step-specific) to learn the available arguments. - -```python -import os -from slack_bolt import App -from slack_bolt.workflows.step import WorkflowStep - -# Initiate the Bolt app as you normally would -app = App( - token=os.environ.get("SLACK_BOT_TOKEN"), - signing_secret=os.environ.get("SLACK_SIGNING_SECRET") -) - -def edit(ack, step, configure): - pass - -def save(ack, view, update): - pass - -def execute(step, complete, fail): - pass - -# Create a new WorkflowStep instance -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) - -# Pass Step to set up listeners -app.step(ws) -``` diff --git a/docs/content/steps/executing-steps.md b/docs/content/steps/executing-steps.md deleted file mode 100644 index 12d557cd0..000000000 --- a/docs/content/steps/executing-steps.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Executing steps from apps -lang: en -slug: /concepts/executing-steps ---- - -:::danger - -Steps from apps are a deprecated feature. - -Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as custom steps for Bolt. - -Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. - -::: - -When your step from app is executed by an end user, your app will receive a [`workflow_step_execute` event](https://api.slack.com/events/workflow_step_execute). The `execute` callback in your `WorkflowStep` configuration will be run when this event is received. - -Using the `inputs` from the `save` callback, this is where you can make third-party API calls, save information to a database, update the user's Home tab, or decide the outputs that will be available to subsequent steps from apps by mapping values to the `outputs` object. - -Within the `execute` callback, your app must either call `complete()` to indicate that the step's execution was successful, or `fail()` to indicate that the step's execution failed. - -Refer to the module documents (common / step-specific) to learn the available arguments. -```python -def execute(step, complete, fail): - inputs = step["inputs"] - # if everything was successful - outputs = { - "task_name": inputs["task_name"]["value"], - "task_description": inputs["task_description"]["value"], - } - complete(outputs=outputs) - - # if something went wrong - error = {"message": "Just testing step failure!"} - fail(error=error) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` diff --git a/docs/content/steps/saving-steps.md b/docs/content/steps/saving-steps.md deleted file mode 100644 index 079cf5d71..000000000 --- a/docs/content/steps/saving-steps.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: Saving step configurations -lang: en -slug: /concepts/saving-steps ---- - -:::danger - -Steps from apps are a deprecated feature. - -Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as custom steps for Bolt. - -Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. - -::: - -After the configuration modal is opened, your app will listen for the `view_submission` event. The `save` callback in your `WorkflowStep` configuration will be run when this event is received. - -Within the `save` callback, the `update()` method can be used to save the builder's step configuration by passing in the following arguments: - -- `inputs` is a dictionary representing the data your app expects to receive from the user upon step execution. -- `outputs` is a list of objects containing data that your app will provide upon the step's completion. Outputs can then be used in subsequent steps of the workflow. -- `step_name` overrides the default Step name -- `step_image_url` overrides the default Step image - -To learn more about how to structure these parameters, [read the documentation](https://api.slack.com/reference/workflows/workflow_step). - -Refer to the module documents (common / step-specific) to learn the available arguments. -```python -def save(ack, view, update): - ack() - - values = view["state"]["values"] - task_name = values["task_name_input"]["name"] - task_description = values["task_description_input"]["description"] - - inputs = { - "task_name": {"value": task_name["value"]}, - "task_description": {"value": task_description["value"]} - } - outputs = [ - { - "type": "text", - "name": "task_name", - "label": "Task name", - }, - { - "type": "text", - "name": "task_description", - "label": "Task description", - } - ] - update(inputs=inputs, outputs=outputs) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` diff --git a/docs/content/steps/steps.md b/docs/content/steps/steps.md deleted file mode 100644 index 64604ba78..000000000 --- a/docs/content/steps/steps.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Overview of steps from apps -lang: en -slug: /concepts/steps ---- - -:::danger - -Steps from apps are a deprecated feature. - -Steps from apps are different than, and not interchangeable with, Slack automation workflows. We encourage those who are currently publishing steps from apps to consider the new [Slack automation features](https://api.slack.com/automation), such as custom steps for Bolt. - -Please [read the Slack API changelog entry](https://api.slack.com/changelog/2023-08-workflow-steps-from-apps-step-back) for more information. - -::: - -Steps from apps for legacy workflows are now deprecated. Use new [custom steps](https://api.slack.com/automation/functions/custom-bolt). - -Steps from apps allow your app to create and process steps that users can add using [Workflow Builder](https://api.slack.com/workflows). - -Steps from apps are made up of three distinct user events: - -- Adding or editing the step in a Workflow -- Saving or updating the step's configuration -- The end user's execution of the step - -All three events must be handled for a step from app to function. - -Read more about steps from apps in the [API documentation](https://api.slack.com/workflows/steps). diff --git a/docs/content/tutorial/ai-chatbot.md b/docs/content/tutorial/ai-chatbot.md index 9fec871a0..9f4038f36 100644 --- a/docs/content/tutorial/ai-chatbot.md +++ b/docs/content/tutorial/ai-chatbot.md @@ -12,7 +12,7 @@ In this tutorial, you'll learn how to bring the power of AI into your Slack work Before getting started, you will need the following: -* a development workspace where you have permissions to install apps. If you don’t have a workspace, go ahead and set that up now—you can [go here](https://slack.com/get-started#create) to create one, or you can join the [Developer Program](https://api.slack.com/developer-program) and provision a sandbox with access to all Slack features for free. +* a development workspace where you have permissions to install apps. If you don’t have a workspace, go ahead and set that up now — you can [go here](https://slack.com/get-started#create) to create one, or you can join the [Developer Program](https://api.slack.com/developer-program) and provision a sandbox with access to all Slack features for free. * a development environment with [Python 3.6](https://www.python.org/downloads/) or later. * an Anthropic or OpenAI account with sufficient credits, and in which you have generated a secret key. @@ -144,7 +144,7 @@ When finished, click **Finish Up**, then click **Publish** to make the workflow In order for Bolty to provide summaries of recent conversation in a channel, Bolty _must_ be a member of that channel. -1. Invite Bolty to a channel that you are able to leave and rejoin (for example, not the **#general** channel or a private channel someone else created) by mentioning the app in the channel—i.e., tagging **@Bolty** in the channel and sending your message. +1. Invite Bolty to a channel that you are able to leave and rejoin (for example, not the **#general** channel or a private channel someone else created) by mentioning the app in the channel — i.e., tagging **@Bolty** in the channel and sending your message. 2. Slackbot will prompt you to either invite Bolty to the channel, or do nothing. Click **Invite Them**. Now when new users join the channel, the workflow you just created will be kicked off. To test this, leave the channel you just invited Bolty to and rejoin it. This will kick off your workflow and you'll receive a direct message from **Welcome to the channel**. Click the **Yes, give me a summary** button, and Bolty will summarize the recent conversations in the channel you joined. @@ -167,7 +167,6 @@ It retrieves the conversation history, parses it, generates a summary using an A and completes the workflow with the summary or fails if an error occurs. """ - def handle_summary_function_callback( ack: Ack, inputs: dict, fail: Fail, logger: Logger, client: WebClient, complete: Complete ): diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index d6c3aa5a7..b7a5ad096 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -55,6 +55,23 @@ const config = { to: "/", from: ["/concepts", "/concepts/basic", "/concepts/advanced"], }, + { + to: '/concepts/actions', + from: [ + '/concepts/action-listening', + '/concepts/action-responding' + ], + }, + { + to: '/legacy/steps-from-apps', + from: [ + '/concepts/steps', + '/concepts/creating-steps', + '/concepts/adding-editing-steps', + '/concepts/saving-steps', + '/concepts/executing-steps' + ], + }, ], }, ], diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-respond.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-respond.md deleted file mode 100644 index 3a31a05c5..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-respond.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: アクションぞの応答 -lang: ja-jp -slug: /concepts/action-respond ---- - -アクションぞの応答には、䞻に 2 ぀の方法がありたす。1 ぀目の最も䞀般的なやり方は `say()` を䜿甚する方法です。そのリク゚ストが発生した䌚話チャンネルや DMにメッセヌゞを返したす。 - -2 ぀目は、`respond()` を䜿甚する方法です。これは、アクションに関連づけられた `response_url` を䜿ったメッセヌゞ送信を行うためのナヌティリティです。 - -指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください。 -```python -# 'approve_button' ずいう action_id のむンタラクティブコンポヌネントがトリガヌされるず、このリスナヌが呌ばれる -@app.action("approve_button") -def approve_request(ack, say): - # アクションのリク゚ストを確認 - ack() - say("Request approved 👍") -``` - -
- -respond() の利甚 - - -`respond()` は `response_url` を䜿っお送信するずきに䟿利なメ゜ッドで、これらず同じような動䜜をしたす。投皿するメッセヌゞのペむロヌドには、党おの[メッセヌゞペむロヌドのプロパティ](https://api.slack.com/reference/messaging/payload)ずオプションのプロパティずしお `response_type`倀は `"in_channel"` たたは `"ephemeral"`、`replace_original`、`delete_original`、`unfurl_links`、`unfurl_media` などを指定できたす。こうするこずによっおアプリから送信されるメッセヌゞは、やり取りの発生元に反映されたす。 - -```python -# 'user_select' ずいう action_id を持぀アクションのトリガヌをリッスン -@app.action("user_select") -def select_user(ack, action, respond): - ack() - respond(f"You selected <@{action['selected_user']}>") -``` - -
\ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/acknowledge.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/acknowledge.md similarity index 99% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/acknowledge.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/acknowledge.md index d180a966d..3e3523417 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/acknowledge.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/acknowledge.md @@ -4,8 +4,6 @@ lang: ja-jp slug: /concepts/acknowledge --- - - アクションaction、コマンドcommand、ショヌトカットshortcut、オプションoptions、およびモヌダルからのデヌタ送信view_submissionの各リク゚ストは、**必ず** `ack()` 関数を䜿っお確認を行う必芁がありたす。これによっおリク゚ストが受信されたこずが Slack に認識され、Slack のナヌザヌむンタヌフェむスが適切に曎新されたす。 リク゚ストの皮類によっおは、確認で通知方法が異なる堎合がありたす。䟋えば、倖郚デヌタ゜ヌスを䜿甚する遞択メニュヌのオプションのリク゚ストに察する確認では、適切な[オプション](https://api.slack.com/reference/block-kit/composition-objects#option)のリストずずもに `ack()` を呌び出したす。モヌダルからのデヌタ送信に察する確認では、 `response_action` を枡すこずで[モヌダルの曎新](/concepts/view_submissions)などを行えたす。 @@ -14,8 +12,6 @@ slug: /concepts/acknowledge FaaS / serverless 環境を䜿う堎合、 `ack()` するタむミングが異なりたす。 これに関する詳现は [Lazy listeners (FaaS)](/concepts/lazy-listeners) を参照しおください。 - - 指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください。 ```python # 倖郚デヌタを䜿甚する遞択メニュヌオプションに応答するサンプル diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-listening.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/actions.md similarity index 51% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-listening.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/actions.md index 7be3340d6..799436854 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/action-listening.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/actions.md @@ -1,9 +1,11 @@ --- -title: アクションのリスニング +title: アクション lang: ja-jp -slug: /concepts/action-listening +slug: /concepts/actions --- +## アクションのリスニング + Bolt アプリは `action` メ゜ッドを甚いお、ボタンのクリック、メニュヌの遞択、メッセヌゞショヌトカットなどのナヌザヌのアクションをリッスンするこずができたす。 アクションは `str` 型たたは `re.Pattern` 型の `action_id` でフィルタリングできたす。`action_id` は、Slack プラットフォヌム䞊のむンタラクティブコンポヌネントを区別する䞀意の識別子ずしお機胜したす。 @@ -19,10 +21,7 @@ def update_message(ack): # アクションぞの反応ずしおメッセヌゞを曎新 ``` -
- -

制玄付きオブゞェクトを䜿甚したアクションのリスニング

-
+### 制玄付きオブゞェクトを䜿甚したアクションのリスニング 制玄付きのオブゞェクトを䜿甚するず、`block_id` ず `action_id` をそれぞれ、たたは任意に組み合わせおリッスンできたす。オブゞェクト内の制玄は、`str` 型たたは `re.Pattern` 型で指定できたす。 @@ -44,4 +43,30 @@ def update_message(ack, body, client): ) ``` -
\ No newline at end of file +## アクションぞの応答 + +アクションぞの応答には、䞻に 2 ぀の方法がありたす。1 ぀目の最も䞀般的なやり方は `say()` を䜿甚する方法です。そのリク゚ストが発生した䌚話チャンネルや DMにメッセヌゞを返したす。 + +2 ぀目は、`respond()` を䜿甚する方法です。これは、アクションに関連づけられた `response_url` を䜿ったメッセヌゞ送信を行うためのナヌティリティです。 + +指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください。 +```python +# 'approve_button' ずいう action_id のむンタラクティブコンポヌネントがトリガヌされるず、このリスナヌが呌ばれる +@app.action("approve_button") +def approve_request(ack, say): + # アクションのリク゚ストを確認 + ack() + say("Request approved 👍") +``` + +### respond() の利甚 + +`respond()` は `response_url` を䜿っお送信するずきに䟿利なメ゜ッドで、これらず同じような動䜜をしたす。投皿するメッセヌゞのペむロヌドには、党おの[メッセヌゞペむロヌドのプロパティ](https://api.slack.com/reference/messaging/payload)ずオプションのプロパティずしお `response_type`倀は `"in_channel"` たたは `"ephemeral"`、`replace_original`、`delete_original`、`unfurl_links`、`unfurl_media` などを指定できたす。こうするこずによっおアプリから送信されるメッセヌゞは、やり取りの発生元に反映されたす。 + +```python +# 'user_select' ずいう action_id を持぀アクションのトリガヌをリッスン +@app.action("user_select") +def select_user(ack, action, respond): + ack() + respond(f"You selected <@{action['selected_user']}>") +``` diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/adapters.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/adapters.md similarity index 99% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/adapters.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/adapters.md index 4dfd0f9a1..78c94fca4 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/adapters.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/adapters.md @@ -12,7 +12,6 @@ slug: /concepts/adapters すべおのアダプタヌの䞀芧ず、蚭定や䜿い方のサンプルは、リポゞトリの `examples` フォルダをご芧ください。 - ```python from slack_bolt import App app = App( diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/app-home.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/app-home.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/app-home.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/app-home.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/assistant.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/assistant.md similarity index 99% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/assistant.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/assistant.md index c09f7979e..d3b54e760 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/assistant.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/assistant.md @@ -74,7 +74,6 @@ app.use(assistant) リスナヌに指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください。 - ナヌザヌがチャンネルの暪でアシスタントスレッドを開いた堎合、そのチャンネルの情報は、そのスレッドの `AssistantThreadContext` デヌタずしお保持され、 `get_thread_context` ナヌティリティを䜿っおアクセスするこずができたす。Bolt がこのナヌティリティを提䟛しおいる理由は、埌続のナヌザヌメッセヌゞ投皿のむベントペむロヌドに最新のスレッドのコンテキスト情報は含たれないためです。そのため、アプリはコンテキスト情報が倉曎されたタむミングでそれを䜕らかの方法で保存し、埌続のメッセヌゞむベントのリスナヌコヌドから参照できるようにする必芁がありたす。 そのナヌザヌがチャンネルを切り替えた堎合、`assistant_thread_context_changed` むベントがあなたのアプリに送信されたす。䞊蚘のコヌド䟋のように組み蟌みの `Assistant` ミドルりェアをカスタム蚭定なしで利甚しおいる堎合、この曎新されたチャンネル情報は、自動的にこのアシスタントボットからの最初の返信のメッセヌゞメタデヌタずしお保存されたす。これは、組み蟌みの仕組みを䜿う堎合は、このコンテキスト情報を自前で甚意したデヌタストアに保存する必芁はないずいうこずです。この組み蟌みの仕組みの唯䞀の短所は、远加の Slack API 呌び出しによる凊理時間のオヌバヌヘッドです。具䜓的には `get_thread_context` を実行したずきに、この保存されたメッセヌゞメタデヌタにアクセスするために `conversations.history` API が呌び出されたす。 @@ -89,11 +88,9 @@ assistant = Assistant(thread_context_store=FileAssistantThreadContextStore()) このリファレンス実装はロヌカルファむルに䟝存しおおり、本番環境での利甚は掚奚したせん。本番アプリでは `AssistantThreadContextStore` を継承した自前のクラスを䜿うようにしおください。 -
+最埌に、動䜜する完党なサンプルコヌド䟋を確認したい堎合は、私たちが GitHub 䞊で提䟛しおいる[サンプルアプリのリポゞトリ](https://github.com/slack-samples/bolt-python-assistant-template)をチェックしおみおください。 - -アシスタントスレッドでの Block Kit むンタラクション - +## アシスタントスレッドでの Block Kit むンタラクション より高床なナヌスケヌスでは、䞊のようなプロンプト䟋の提案ではなく Block Kit のボタンなどを䜿いたいずいう堎合があるかもしれたせん。そしお、埌続の凊理のために[構造化されたメッセヌゞメタデヌタ](https://api.slack.com/metadata)を含むメッセヌゞを送信したいずいう堎合もあるでしょう。 @@ -229,11 +226,6 @@ def respond_to_user_messages(logger: logging.Logger, set_status: SetStatus, say: logger.exception(f"Failed to respond to an inquiry: {e}") say(f":warning: Sorry, something went wrong during processing your request (error: {e})") - # このミドルりェアを Bolt アプリに远加したす app.use(assistant) -``` - -
- -最埌に、動䜜する完党なサンプルコヌド䟋を確認したい堎合は、私たちが GitHub 䞊で提䟛しおいる[サンプルアプリのリポゞトリ](https://github.com/slack-samples/bolt-python-assistant-template)をチェックしおみおください。 \ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/async.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/async.md similarity index 96% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/async.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/async.md index 7ea6c7dc9..19609be89 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/async.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/async.md @@ -8,7 +8,6 @@ slug: /concepts/async 非同期バヌゞョンのプロゞェクトのサンプルは、リポゞトリの `examples` フォルダにありたす。 - ```python # aiohttp のむンストヌルが必芁です from slack_bolt.async_app import AsyncApp @@ -27,11 +26,7 @@ if __name__ == "__main__": app.start(3000) ``` -
- ->他のフレヌムワヌクを䜿甚する - - +## 他のフレヌムワヌクを䜿甚する `AsyncApp#start()` では内郚的に [`AIOHTTP`](https://docs.aiohttp.org/) のWebサヌバヌが実装されおいたす。必芁に応じお、受信リク゚ストの凊理に `AIOHTTP` 以倖のフレヌムワヌクを䜿甚するこずができたす。 @@ -46,7 +41,6 @@ pip install slack_bolt sanic uvicorn uvicorn async_app:api --reload --port 3000 --log-level debug ``` - ```python from slack_bolt.async_app import AsyncApp app = AsyncApp() @@ -74,5 +68,4 @@ async def endpoint(req: Request): if __name__ == "__main__": api.run(host="0.0.0.0", port=int(os.environ.get("PORT", 3000))) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/authenticating-oauth.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/authenticating-oauth.md similarity index 98% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/authenticating-oauth.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/authenticating-oauth.md index b1478ee3b..e72f27146 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/authenticating-oauth.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/authenticating-oauth.md @@ -35,10 +35,7 @@ app = App( ) ``` -
- -OAuth デフォルト蚭定をカスタマむズ - +## OAuth デフォルト蚭定をカスタマむズ `oauth_settings` を䜿っお OAuth モゞュヌルのデフォルト蚭定を䞊曞きするこずができたす。このカスタマむズされた蚭定は App の初期化時に枡したす。以䞋の情報を倉曎可胜です: @@ -90,6 +87,4 @@ app = App( callback_options=callback_options, ), ) -``` - -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/authorization.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/authorization.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/authorization.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/authorization.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/commands.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/commands.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/commands.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/commands.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/context.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/context.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/context.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/context.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/custom-adapters.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/custom-adapters.md similarity index 99% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/custom-adapters.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/custom-adapters.md index 7d2e63a91..b72d48ded 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/custom-adapters.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/custom-adapters.md @@ -22,7 +22,6 @@ slug: /concepts/custom-adapters カスタムのアダプタヌに関連した詳しいサンプルに぀いおは、[組み蟌みのアダプタヌ](https://github.com/slackapi/bolt-python/tree/main/slack_bolt/adapter)の実装を参考にしおください。 - ```python # Flask で必芁なパッケヌゞをむンポヌトしたす from flask import Request, Response, make_response diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/custom-steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/custom-steps.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/custom-steps.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/custom-steps.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/errors.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/errors.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/errors.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/errors.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/event-listening.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/event-listening.md similarity index 95% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/event-listening.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/event-listening.md index 6d0409bb0..e54989255 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/event-listening.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/event-listening.md @@ -19,17 +19,12 @@ def ask_for_introduction(event, say): say(text=text, channel=welcome_channel_id) ``` -
- - -メッセヌゞのサブタむプのフィルタリング - +## メッセヌゞのサブタむプのフィルタリング `message()` リスナヌは `event("message")` ず等䟡の機胜を提䟛したす。 `subtype` ずいう远加のキヌを指定しお、むベントのサブタむプでフィルタリングするこずもできたす。よく䜿われるサブタむプには、`bot_message` や `message_replied` がありたす。詳しくは[メッセヌゞむベントペヌゞ](https://api.slack.com/events/message#message_subtypes)を参照しおください。サブタむプなしのむベントだけにフィルタヌするために明に `None` を指定するこずもできたす。 - ```python # 倉曎されたすべおのメッセヌゞに䞀臎 @app.event({ @@ -39,5 +34,4 @@ def ask_for_introduction(event, say): def log_message_change(logger, event): user, text = event["user"], event["text"] logger.info(f"The user {user} changed the message to {text}") -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/global-middleware.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/global-middleware.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/global-middleware.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/global-middleware.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/lazy-listeners.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/lazy-listeners.md similarity index 98% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/lazy-listeners.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/lazy-listeners.md index de5f538e8..25eb6294c 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/lazy-listeners.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/lazy-listeners.md @@ -14,7 +14,6 @@ Lazy リスナヌ関数は、FaaS 環境ぞの Slack アプリのデプロむを * `ack: Callable`: 3 秒以内での `ack()` メ゜ッドの呌び出しを担圓したす。 * `lazy: List[Callable]` : リク゚ストに関する時間のかかる凊理のハンドリングを担圓したす。Lazy 関数からは `ack()` にアクセスするこずはできたせん。 - ```python def respond_to_slack_within_3_seconds(body, ack): text = body.get("text") @@ -36,11 +35,7 @@ app.command("/start-process")( ) ``` -
- -AWS Lambda を䜿甚した䟋 - - +## AWS Lambda を䜿甚した䟋 このサンプルは、[AWS Lambda](https://aws.amazon.com/lambda/) にコヌドをデプロむしたす。[`examples` フォルダ](https://github.com/slackapi/bolt-python/tree/main/examples/aws_lambda)にはほかにもサンプルが甚意されおいたす。 @@ -60,7 +55,6 @@ echo 'slack_bolt' > requirements.txt lambda deploy --config-file config.yaml --requirements requirements.txt ``` - ```python from slack_bolt import App from slack_bolt.adapter.aws_lambda import SlackRequestHandler @@ -107,5 +101,4 @@ def handler(event, context): } ] } -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/listener-middleware.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/listener-middleware.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/listener-middleware.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/listener-middleware.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/logging.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/logging.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/logging.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/logging.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-listening.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-listening.md similarity index 94% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-listening.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-listening.md index a30620abd..f9ccf7d17 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-listening.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-listening.md @@ -17,10 +17,7 @@ def say_hello(message, say): say(f"Hi there, <@{user}>!") ``` -
- -正芏衚珟パタヌンの利甚 - +## 正芏衚珟パタヌンの利甚 文字列の代わりに `re.compile()` メ゜ッドを䜿甚すれば、より现やかな条件指定ができたす。 @@ -32,5 +29,4 @@ def say_hello_regex(say, context): # 正芏衚珟のマッチ結果は context.matches に蚭定される greeting = context['matches'][0] say(f"{greeting}, how are you?") -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-sending.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-sending.md similarity index 96% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-sending.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-sending.md index 8b5c9e7e5..e109a0f4d 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/message-sending.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/message-sending.md @@ -15,10 +15,8 @@ slug: /concepts/message-sending def ask_who(message, say): say("_Who's there?_") ``` -
- -ブロックを甚いたメッセヌゞの送信 - + +## ブロックを甚いたメッセヌゞの送信 `say()` は、より耇雑なメッセヌゞペむロヌドを受け付けるので、メッセヌゞに機胜やリッチな構造を䞎えるこずが容易です。 @@ -44,5 +42,4 @@ def show_datepicker(event, say): blocks=blocks, text="Pick a date for me to remind you" ) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/opening-modals.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/opening-modals.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/opening-modals.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/opening-modals.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/options.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/select-menu-options.md similarity index 99% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/options.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/select-menu-options.md index 4838b2a75..78f7dcdb4 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/options.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/select-menu-options.md @@ -33,4 +33,4 @@ def show_options(ack, payload): if keyword is not None and len(keyword) > 0: options = [o for o in options if keyword in o["text"]["text"]] ack(options=options) -``` \ No newline at end of file +``` diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/shortcuts.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/shortcuts.md similarity index 97% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/shortcuts.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/shortcuts.md index 5824fbb65..e12b576ca 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/shortcuts.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/shortcuts.md @@ -53,13 +53,7 @@ def open_modal(ack, shortcut, client): ) ``` -
- - -制玄付きオブゞェクトを䜿甚したショヌトカットのリスニング - - - +## 制玄付きオブゞェクトを䜿甚したショヌトカットのリスニング 制玄付きオブゞェクトを䜿っお `callback_id` や `type` によるリッスンできたす。オブゞェクト内の制玄は `str` 型たたは `re.Pattern` オブゞェクトを䜿甚できたす。 @@ -97,5 +91,4 @@ def open_modal(ack, shortcut, client): ] } ) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/socket-mode.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/socket-mode.md similarity index 98% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/socket-mode.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/socket-mode.md index a4c486cbd..ad4f6c8f0 100644 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/socket-mode.md +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/socket-mode.md @@ -36,16 +36,12 @@ if __name__ == "__main__": handler.start() ``` -
- -Async (asyncio) の利甚 - +## Async (asyncio) の利甚 aiohttp のような asyncio をベヌスずしたアダプタヌを䜿う堎合、アプリケヌション党䜓が asyncio の async/await プログラミングモデルで実装されおいる必芁がありたす。`AsyncApp` を動䜜させるためには `AsyncSocketModeHandler` ずその async なミドルりェアやリスナヌを利甚したす。 `AsyncApp` の䜿い方に぀いおの詳现は、[Async (asyncio) の利甚](/concepts/async)や、関連する[サンプルコヌド䟋](https://github.com/slackapi/bolt-python/tree/main/examples)を参考にしおください。 - ```python from slack_bolt.app.async_app import AsyncApp # デフォルトは aiohttp を䜿った実装 @@ -62,5 +58,4 @@ async def main(): if __name__ == "__main__": import asyncio asyncio.run(main()) -``` -
\ No newline at end of file +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/token-rotation.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/token-rotation.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/advanced/token-rotation.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/token-rotation.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/updating-pushing-views.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/updating-pushing-views.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/updating-pushing-views.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/updating-pushing-views.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/view_submissions.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/view-submissions.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/view_submissions.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/view-submissions.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/web-api.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/web-api.md similarity index 100% rename from docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/basic/web-api.md rename to docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/concepts/web-api.md diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/legacy/steps-from-apps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/legacy/steps-from-apps.md new file mode 100644 index 000000000..4717de480 --- /dev/null +++ b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/legacy/steps-from-apps.md @@ -0,0 +1,193 @@ +--- +title: ワヌクフロヌステップの抂芁 +lang: ja-jp +slug: /concepts/steps-from-apps +--- + +アプリによるワヌクフロヌステップでは、凊理をアプリ偎で行うカスタムのワヌクフロヌステップを提䟛するこずができたす。ナヌザヌは[ワヌクフロヌビルダヌ](https://api.slack.com/workflows)を䜿っおこれらのステップをワヌクフロヌに远加できたす。 + +ワヌクフロヌステップは、次の 3 ぀のナヌザヌむベントで構成されたす。 + +- ワヌクフロヌステップをワヌクフロヌに远加・倉曎する +- ワヌクフロヌ内のステップの蚭定内容を曎新する +- ゚ンドナヌザヌがそのステップを実行する + +ワヌクフロヌステップを機胜させるためには、これら 3 ぀のむベントすべおに察応する必芁がありたす。 + +アプリを䜿ったワヌクフロヌステップに関する詳现は、[API ドキュメント](https://api.slack.com/workflows/steps)を参照しおください。 + +## ステップの定矩 + +ワヌクフロヌステップの䜜成には、Bolt が提䟛する `WorkflowStep` クラスを利甚したす。 + +ステップの `callback_id` ず蚭定オブゞェクトを指定しお、`WorkflowStep` の新しいむンスタンスを䜜成したす。 + +蚭定オブゞェクトは、`edit`、`save`、`execute` ずいう 3 ぀のキヌを持ちたす。それぞれのキヌは、単䞀のコヌルバック、たたはコヌルバックのリストである必芁がありたす。すべおのコヌルバックは、ワヌクフロヌステップのむベントに関する情報を保持する `step` オブゞェクトにアクセスできたす。 + +`WorkflowStep` のむンスタンスを䜜成したら、それを`app.step()` メ゜ッドに枡したす。これによっお、アプリがワヌクフロヌステップのむベントをリッスンし、蚭定オブゞェクトで指定されたコヌルバックを䜿っおそれに応答できるようになりたす。 + +たた、デコレヌタヌずしお利甚できる `WorkflowStepBuilder` クラスを䜿っおワヌクフロヌステップを定矩するこずもできたす。 詳现は、[こちらのドキュメント](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/step.html#slack_bolt.workflows.step.step.WorkflowStepBuilder)のコヌド䟋などを参考にしおください。 + +指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 + +```python +import os +from slack_bolt import App +from slack_bolt.workflows.step import WorkflowStep + +# い぀も通りBolt アプリを起動する +app = App( + token=os.environ.get("SLACK_BOT_TOKEN"), + signing_secret=os.environ.get("SLACK_SIGNING_SECRET") +) + +def edit(ack, step, configure): + pass + +def save(ack, view, update): + pass + +def execute(step, complete, fail): + pass + +# WorkflowStep の新しいむンスタンスを䜜成する +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +# ワヌクフロヌステップを枡しおリスナヌを蚭定する +app.step(ws) +``` + +## ステップの远加・線集 + +䜜成したワヌクフロヌステップがワヌクフロヌに远加たたはその蚭定を倉曎されるタむミングで、[`workflow_step_edit` むベントがアプリに送信されたす](https://api.slack.com/reference/workflows/workflow_step_edit)。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `edit` コヌルバックが実行されたす。 + +ステップの远加ず線集のどちらが行われるずきも、[ワヌクフロヌステップの蚭定モヌダル](https://api.slack.com/reference/workflows/configuration-view)をビルダヌに送信する必芁がありたす。このモヌダルは、そのステップ独自の蚭定を遞択するための堎所です。通垞のモヌダルより制限が匷く、䟋えば `title`、`submit`、`close` のプロパティを含めるこずができたせん。蚭定モヌダルの `callback_id` は、デフォルトではワヌクフロヌステップず同じものになりたす。 + +`edit` コヌルバック内で `configure()` ナヌティリティを䜿甚するず、察応する `blocks` 匕数にビュヌのblocks 郚分だけを枡しお、ステップの蚭定モヌダルを簡単に衚瀺させるこずができたす。必芁な入力内容が揃うたで蚭定の保存を無効にするには、`True` の倀をセットした `submit_disabled` を枡したす。 + +蚭定モヌダルの開き方に関する詳现は、[こちらのドキュメント](https://api.slack.com/workflows/steps#handle_config_view)を参照しおください。 + +指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 + +```python +def edit(ack, step, configure): + ack() + + blocks = [ + { + "type": "input", + "block_id": "task_name_input", + "element": { + "type": "plain_text_input", + "action_id": "name", + "placeholder": {"type": "plain_text", "text":"Add a task name"}, + }, + "label": {"type": "plain_text", "text":"Task name"}, + }, + { + "type": "input", + "block_id": "task_description_input", + "element": { + "type": "plain_text_input", + "action_id": "description", + "placeholder": {"type": "plain_text", "text":"Add a task description"}, + }, + "label": {"type": "plain_text", "text":"Task description"}, + }, + ] + configure(blocks=blocks) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` + +## ステップの蚭定の保存 + +蚭定モヌダルを開いた埌、アプリは `view_submission` むベントをリッスンしたす。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `save` コヌルバックが実行されたす。 + +`save` コヌルバック内では、`update()` メ゜ッドを䜿っお、ワヌクフロヌに远加されたステップの蚭定を保存するこずができたす。このメ゜ッドには次の匕数を指定したす。 + +- `inputs` : ナヌザヌがワヌクフロヌステップを実行したずきにアプリが受け取る予定のデヌタを衚す蟞曞型の倀です。 +- `outputs` : ワヌクフロヌステップの完了時にアプリが出力するデヌタが蚭定されたオブゞェクトのリストです。この outputs は、ワヌクフロヌの埌続のステップで利甚するこずができたす。 +- `step_name` : ステップのデフォルトの名前をオヌバヌラむドしたす。 +- `step_image_url` : ステップのデフォルトの画像をオヌバヌラむドしたす。 + +これらのパラメヌタの構成方法に関する詳现は、[こちらのドキュメント](https://api.slack.com/reference/workflows/workflow_step)を参照しおください。 + +指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 + +```python +def save(ack, view, update): + ack() + + values = view["state"]["values"] + task_name = values["task_name_input"]["name"] + task_description = values["task_description_input"]["description"] + + inputs = { + "task_name": {"value": task_name["value"]}, + "task_description": {"value": task_description["value"]} + } + outputs = [ + { + "type": "text", + "name": "task_name", + "label":"Task name", + }, + { + "type": "text", + "name": "task_description", + "label":"Task description", + } + ] + update(inputs=inputs, outputs=outputs) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` + +## ステップの実行 + +゚ンドナヌザヌがワヌクフロヌステップを実行するず、アプリに [`workflow_step_execute` むベントが送信されたす](https://api.slack.com/events/workflow_step_execute)。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `execute` コヌルバックが実行されたす。 + +`save` コヌルバックで取り出した `inputs` を䜿っお、サヌドパヌティの API を呌び出す、情報をデヌタベヌスに保存する、ナヌザヌのホヌムタブを曎新するずいった凊理を実行するこずができたす。たた、ワヌクフロヌの埌続のステップで利甚する出力倀を `outputs` オブゞェクトに蚭定したす。 + +`execute` コヌルバック内では、`complete()` を呌び出しおステップの実行が成功したこずを瀺すか、`fail()` を呌び出しおステップの実行が倱敗したこずを瀺す必芁がありたす。 + +指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 +```python +def execute(step, complete, fail): + inputs = step["inputs"] + # すべおの凊理が成功した堎合 + outputs = { + "task_name": inputs["task_name"]["value"], + "task_description": inputs["task_description"]["value"], + } + complete(outputs=outputs) + + # 倱敗した凊理がある堎合 + error = {"message":"Just testing step failure!"} + fail(error=error) + +ws = WorkflowStep( + callback_id="add_task", + edit=edit, + save=save, + execute=execute, +) +app.step(ws) +``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/adding-editing-steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/adding-editing-steps.md deleted file mode 100644 index 24b85bfa7..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/adding-editing-steps.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: ステップの远加・線集 -lang: ja-jp -slug: /concepts/adding-editing-steps ---- - -䜜成したワヌクフロヌステップがワヌクフロヌに远加たたはその蚭定を倉曎されるタむミングで、[`workflow_step_edit` むベントがアプリに送信されたす](https://api.slack.com/reference/workflows/workflow_step_edit)。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `edit` コヌルバックが実行されたす。 - -ステップの远加ず線集のどちらが行われるずきも、[ワヌクフロヌステップの蚭定モヌダル](https://api.slack.com/reference/workflows/configuration-view)をビルダヌに送信する必芁がありたす。このモヌダルは、そのステップ独自の蚭定を遞択するための堎所です。通垞のモヌダルより制限が匷く、䟋えば `title`、`submit`、`close` のプロパティを含めるこずができたせん。蚭定モヌダルの `callback_id` は、デフォルトではワヌクフロヌステップず同じものになりたす。 - -`edit` コヌルバック内で `configure()` ナヌティリティを䜿甚するず、察応する `blocks` 匕数にビュヌのblocks 郚分だけを枡しお、ステップの蚭定モヌダルを簡単に衚瀺させるこずができたす。必芁な入力内容が揃うたで蚭定の保存を無効にするには、`True` の倀をセットした `submit_disabled` を枡したす。 - -蚭定モヌダルの開き方に関する詳现は、[こちらのドキュメント](https://api.slack.com/workflows/steps#handle_config_view)を参照しおください。 - -指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 - -```python -def edit(ack, step, configure): - ack() - - blocks = [ - { - "type": "input", - "block_id": "task_name_input", - "element": { - "type": "plain_text_input", - "action_id": "name", - "placeholder": {"type": "plain_text", "text":"Add a task name"}, - }, - "label": {"type": "plain_text", "text":"Task name"}, - }, - { - "type": "input", - "block_id": "task_description_input", - "element": { - "type": "plain_text_input", - "action_id": "description", - "placeholder": {"type": "plain_text", "text":"Add a task description"}, - }, - "label": {"type": "plain_text", "text":"Task description"}, - }, - ] - configure(blocks=blocks) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/creating-steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/creating-steps.md deleted file mode 100644 index 889543767..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/creating-steps.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: ステップの定矩 -lang: ja-jp -slug: /concepts/creating-steps ---- - -ワヌクフロヌステップの䜜成には、Bolt が提䟛する `WorkflowStep` クラスを利甚したす。 - -ステップの `callback_id` ず蚭定オブゞェクトを指定しお、`WorkflowStep` の新しいむンスタンスを䜜成したす。 - -蚭定オブゞェクトは、`edit`、`save`、`execute` ずいう 3 ぀のキヌを持ちたす。それぞれのキヌは、単䞀のコヌルバック、たたはコヌルバックのリストである必芁がありたす。すべおのコヌルバックは、ワヌクフロヌステップのむベントに関する情報を保持する `step` オブゞェクトにアクセスできたす。 - -`WorkflowStep` のむンスタンスを䜜成したら、それを`app.step()` メ゜ッドに枡したす。これによっお、アプリがワヌクフロヌステップのむベントをリッスンし、蚭定オブゞェクトで指定されたコヌルバックを䜿っおそれに応答できるようになりたす。 - -たた、デコレヌタヌずしお利甚できる `WorkflowStepBuilder` クラスを䜿っおワヌクフロヌステップを定矩するこずもできたす。 詳现は、[こちらのドキュメント](https://tools.slack.dev/bolt-python/api-docs/slack_bolt/workflows/step/step.html#slack_bolt.workflows.step.step.WorkflowStepBuilder)のコヌド䟋などを参考にしおください。 - -指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 - -```python -import os -from slack_bolt import App -from slack_bolt.workflows.step import WorkflowStep - -# い぀も通りBolt アプリを起動する -app = App( - token=os.environ.get("SLACK_BOT_TOKEN"), - signing_secret=os.environ.get("SLACK_SIGNING_SECRET") -) - -def edit(ack, step, configure): - pass - -def save(ack, view, update): - pass - -def execute(step, complete, fail): - pass - -# WorkflowStep の新しいむンスタンスを䜜成する -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -# ワヌクフロヌステップを枡しおリスナヌを蚭定する -app.step(ws) -``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/executing-steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/executing-steps.md deleted file mode 100644 index e10c7eec3..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/executing-steps.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: ステップの実行 -lang: ja-jp -slug: /concepts/executing-steps ---- - -゚ンドナヌザヌがワヌクフロヌステップを実行するず、アプリに [`workflow_step_execute` むベントが送信されたす](https://api.slack.com/events/workflow_step_execute)。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `execute` コヌルバックが実行されたす。 - -`save` コヌルバックで取り出した `inputs` を䜿っお、サヌドパヌティの API を呌び出す、情報をデヌタベヌスに保存する、ナヌザヌのホヌムタブを曎新するずいった凊理を実行するこずができたす。たた、ワヌクフロヌの埌続のステップで利甚する出力倀を `outputs` オブゞェクトに蚭定したす。 - -`execute` コヌルバック内では、`complete()` を呌び出しおステップの実行が成功したこずを瀺すか、`fail()` を呌び出しおステップの実行が倱敗したこずを瀺す必芁がありたす。 - -指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 -```python -def execute(step, complete, fail): - inputs = step["inputs"] - # すべおの凊理が成功した堎合 - outputs = { - "task_name": inputs["task_name"]["value"], - "task_description": inputs["task_description"]["value"], - } - complete(outputs=outputs) - - # 倱敗した凊理がある堎合 - error = {"message":"Just testing step failure!"} - fail(error=error) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/saving-steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/saving-steps.md deleted file mode 100644 index 94ad32934..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/saving-steps.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: ステップの蚭定の保存 -lang: ja-jp -slug: /concepts/saving-steps ---- - -蚭定モヌダルを開いた埌、アプリは `view_submission` むベントをリッスンしたす。このむベントがアプリに届くず、`WorkflowStep` で蚭定した `save` コヌルバックが実行されたす。 - -`save` コヌルバック内では、`update()` メ゜ッドを䜿っお、ワヌクフロヌに远加されたステップの蚭定を保存するこずができたす。このメ゜ッドには次の匕数を指定したす。 - -- `inputs` : ナヌザヌがワヌクフロヌステップを実行したずきにアプリが受け取る予定のデヌタを衚す蟞曞型の倀です。 -- `outputs` : ワヌクフロヌステップの完了時にアプリが出力するデヌタが蚭定されたオブゞェクトのリストです。この outputs は、ワヌクフロヌの埌続のステップで利甚するこずができたす。 -- `step_name` : ステップのデフォルトの名前をオヌバヌラむドしたす。 -- `step_image_url` : ステップのデフォルトの画像をオヌバヌラむドしたす。 - -これらのパラメヌタの構成方法に関する詳现は、[こちらのドキュメント](https://api.slack.com/reference/workflows/workflow_step)を参照しおください。 - -指定可胜な匕数の䞀芧はモゞュヌルドキュメントを参考にしおください共通 / ステップ甚 - -```python -def save(ack, view, update): - ack() - - values = view["state"]["values"] - task_name = values["task_name_input"]["name"] - task_description = values["task_description_input"]["description"] - - inputs = { - "task_name": {"value": task_name["value"]}, - "task_description": {"value": task_description["value"]} - } - outputs = [ - { - "type": "text", - "name": "task_name", - "label":"Task name", - }, - { - "type": "text", - "name": "task_description", - "label":"Task description", - } - ] - update(inputs=inputs, outputs=outputs) - -ws = WorkflowStep( - callback_id="add_task", - edit=edit, - save=save, - execute=execute, -) -app.step(ws) -``` \ No newline at end of file diff --git a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/steps.md b/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/steps.md deleted file mode 100644 index 881d791b2..000000000 --- a/docs/i18n/ja-jp/docusaurus-plugin-content-docs/current/steps/steps.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: ワヌクフロヌステップの抂芁 -lang: ja-jp -slug: /concepts/steps ---- - -アプリによるワヌクフロヌステップでは、凊理をアプリ偎で行うカスタムのワヌクフロヌステップを提䟛するこずができたす。ナヌザヌは[ワヌクフロヌビルダヌ](https://api.slack.com/workflows)を䜿っおこれらのステップをワヌクフロヌに远加できたす。 - -ワヌクフロヌステップは、次の 3 ぀のナヌザヌむベントで構成されたす。 - -- ワヌクフロヌステップをワヌクフロヌに远加・倉曎する -- ワヌクフロヌ内のステップの蚭定内容を曎新する -- ゚ンドナヌザヌがそのステップを実行する - -ワヌクフロヌステップを機胜させるためには、これら 3 ぀のむベントすべおに察応する必芁がありたす。 - -アプリを䜿ったワヌクフロヌステップに関する詳现は、[API ドキュメント](https://api.slack.com/workflows/steps)を参照しおください。 \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 1a294e33b..7b1db75c2 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -1,82 +1,90 @@ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ const sidebars = { sidebarBoltPy: [ - { - type: "doc", - id: "index", - label: "Bolt for Python", - className: "sidebar-title", - }, - { type: "html", value: "
" }, { type: "category", label: "Guides", - collapsed: false, items: [ + { + type: "doc", + id: "index", + label: "Bolt for Python", + className: "sidebar-title", + }, "getting-started", { type: "category", - label: "Basic concepts", + label: "Slack API calls", + items: ["concepts/message-sending", "concepts/web-api"], + }, + { + type: "category", + label: "Events API", + items: ["concepts/message-listening", "concepts/event-listening"], + }, + { + type: "category", + label: "App UI & Interactivity", + items: [ + "concepts/acknowledge", + "concepts/shortcuts", + "concepts/commands", + "concepts/actions", + "concepts/opening-modals", + "concepts/updating-pushing-views", + "concepts/view-submissions", + "concepts/select-menu-options", + "concepts/app-home", + ], + }, + "concepts/assistant", + "concepts/custom-steps", + { + type: "category", + label: "App Configuration", items: [ - "basic/assistant", - "basic/message-listening", - "basic/message-sending", - "basic/event-listening", - "basic/web-api", - "basic/action-listening", - "basic/action-respond", - "basic/acknowledge", - "basic/shortcuts", - "basic/commands", - "basic/opening-modals", - "basic/updating-pushing-views", - "basic/view_submissions", - "basic/app-home", - "basic/options", - "basic/custom-steps", - "basic/authenticating-oauth", - "basic/socket-mode", + "concepts/socket-mode", + "concepts/errors", + "concepts/logging", + "concepts/async", ], }, { type: "category", - label: "Advanced concepts", + label: "Middleware & Context", items: [ - "advanced/adapters", - "advanced/custom-adapters", - "advanced/async", - "advanced/errors", - "advanced/logging", - "advanced/authorization", - "advanced/token-rotation", - "advanced/listener-middleware", - "advanced/global-middleware", - "advanced/context", - "advanced/lazy-listeners", + "concepts/global-middleware", + "concepts/listener-middleware", + "concepts/context", ], }, + "concepts/lazy-listeners", + { + type: "category", + label: "Adaptors", + items: ["concepts/adapters", "concepts/custom-adapters"], + }, { type: "category", - label: "Steps from apps (Deprecated)", + label: "Authorization & Security", items: [ - "steps/steps", - "steps/executing-steps", - "steps/creating-steps", - "steps/adding-editing-steps", - "steps/saving-steps", + "concepts/authenticating-oauth", + "concepts/authorization", + "concepts/token-rotation", ], }, + { + type: "category", + label: "Legacy", + items: ["concepts/steps-from-apps"], + }, ], }, { type: "html", value: "
" }, { type: "category", label: "Tutorials", - items: [ - "tutorial/getting-started-http", - "tutorial/ai-chatbot", - "tutorial/custom-steps-for-jira", - ], + items: ["tutorial/ai-chatbot", "tutorial/getting-started-http"], }, { type: "html", value: "
" }, {