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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_advanced/adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ order: 0
---

<div class="section-content">
Adapters are responsible for handling and parsing incoming events from Slack to conform to <a href="https://github.com/slackapi/bolt-python/blob/main/slack_bolt/request/request.py">`BoltRequest`</a>, then dispatching those events to your Bolt app.
Adapters are responsible for handling and parsing incoming requests from Slack to conform to <a href="https://github.com/slackapi/bolt-python/blob/main/slack_bolt/request/request.py">`BoltRequest`</a>, then dispatching those requests to your Bolt app.

By default, Bolt will use the built-in <a href="https://docs.python.org/3/library/http.server.html">`HTTPServer`</a> adapter. While this is okay for local development, <b>it is not recommended for production</b>. 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 events.
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 <a href="https://github.com/slackapi/bolt-python/tree/main/examples">`examples` folder</a>.
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_advanced/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ order: 5
---

<div class="section-content">
Authorization is the process of determining which Slack credentials should be available while processing an incoming Slack event.
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](#authenticating-oauth) for details.

For a more custom solution, you can set the `authorize` parameter to a function upon `App` instantiation. The `authorize` function should return [an instance of `AuthorizeResult`](https://github.com/slackapi/bolt-python/blob/main/slack_bolt/authorization/authorize_result.py), which contains information about who and where the event is coming from.
For a more custom solution, you can set the `authorize` parameter to a function upon `App` instantiation. The `authorize` function should return [an instance of `AuthorizeResult`](https://github.com/slackapi/bolt-python/blob/main/slack_bolt/authorization/authorize_result.py), which contains information about who and where the request is coming from.

`AuthorizeResult` should have a few specific properties, all of type `str`:
- Either **`bot_token`** (xoxb) *or* **`user_token`** (xoxp) are **required**. Most apps will use `bot_token` by default. Passing a token allows built-in functions (like `say()`) to work.
- **`bot_user_id`** and **`bot_id`**, if using a `bot_token`.
- **`enterprise_id`** and **`team_id`**, which can be found in events sent to your app.
- **`enterprise_id`** and **`team_id`**, which can be found in requests sent to your app.
- **`user_id`** only when using `user_token`.
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/_advanced/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 9
---

<div class="section-content">
All listeners have access to a `context` dictionary, which can be used to enrich events with additional information. Bolt automatically attaches information that is included in the incoming event, like `user_id`, `team_id`, `channel_id`, and `enterprise_id`.
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.
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_advanced/global_middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 8
---

<div class="section-content">
Global middleware is run for all incoming events, 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.
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.
</div>
Expand Down
6 changes: 3 additions & 3 deletions docs/_advanced/lazy_listener.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ order: 10
<div class="section-content">
⚠️ Lazy listener functions are a beta feature to make it easier to deploy Bolt for Python apps to FaaS environments. As the feature is developed, Bolt for Python's API is subject to change.

Typically you'd call `ack()` as the first step of your listener functions. Calling `ack()` tells Slack that you've received the event and are handling it in within reasonable amount of time (3 seconds).
Typically you'd call `ack()` as the first step of your listener functions. Calling `ack()` tells Slack that you've received the request and are handling it in within reasonable amount of time (3 seconds).

However, apps running on FaaS or similar runtimes that don't allow you to run threads or processes after returning an HTTP response cannot follow this pattern. Instead, you should set the `process_before_response` flag to `True`. This allows you to create a listener that calls `ack()` and handles the event safely, though you still need to complete everything within 3 seconds. For events, while a listener doesn't need `ack()` method call as you normally would, the listener needs to complete within 3 seconds, too.
However, apps running on FaaS or similar runtimes that don't allow you to run threads or processes after returning an HTTP response cannot follow this pattern. Instead, you should set the `process_before_response` flag to `True`. This allows you to create a listener that calls `ack()` and handles the request safely, though you still need to complete everything within 3 seconds. For events, while a listener doesn't need `ack()` method call as you normally would, the listener needs to complete within 3 seconds, too.

Lazy listeners can be a solution for this issue. Rather than acting as a decorator, lazy listeners take two keyword args:
* `ack: Callable`: Responsible for calling `ack()`
* `lazy: List[Callable]`: Responsible for handling any time-consuming processes related to the event. The lazy function does not have access to `ack()`.
* `lazy: List[Callable]`: Responsible for handling any time-consuming processes related to the request. The lazy function does not have access to `ack()`.
</div>

```python
Expand Down
6 changes: 3 additions & 3 deletions docs/_basic/acknowledging_events.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: Acknowledging events
title: Acknowledging requests
lang: en
slug: acknowledge
order: 7
---

<div class="section-content">

Actions, commands, and options events must **always** be acknowledged using the `ack()` function. This lets Slack know that the event was received and updates the Slack user interface accordingly.
Actions, commands, and options requests must **always** be acknowledged using the `ack()` function. This lets Slack know that the request was received and updates the Slack user interface accordingly.

Depending on the type of event, your acknowledgement may be different. For example, when acknowledging a menu selection associated with an external data source, you would call `ack()` with a list of relevant [options](https://api.slack.com/reference/block-kit/composition-objects#option).
Depending on the type of request, your acknowledgement may be different. For example, when acknowledging a menu selection associated with an external data source, you would call `ack()` with a list of relevant [options](https://api.slack.com/reference/block-kit/composition-objects#option).

We recommend calling `ack()` right away before sending a new message or fetching information from your database since you only have 3 seconds to respond.

Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/listening_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Your app can listen to user actions, like button clicks, and menu selects, using

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 event was received from Slack. This is discussed in the [acknowledging events section](#acknowledge).
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](#acknowledge).

</div>

Expand Down
6 changes: 3 additions & 3 deletions docs/_basic/listening_modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 12

<div class="section-content">

If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> contains any input blocks, you must listen to `view_submission` events to receive their values. To listen to `view_submission` events, you can use the built-in `view()` method. `view()` requires a `callback_id` of type `str` or `re.Pattern`.
If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> 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.

Expand All @@ -18,7 +18,7 @@ Read more about view submissions in our <a href="https://api.slack.com/surfaces/
<div>
<span class="annotation">Refer to <a href="https://slack.dev/bolt-python/api-docs/slack_bolt/kwargs_injection/args.html" target="_blank">the module document</a> to learn the available listener arguments.</span>
```python
# Handle a view_submission event
# Handle a view_submission request
@app.view("view_1")
def handle_submission(ack, body, client, view, logger):
# Assume there's an input block with `block_c` as the block_id and `dreamy_input`
Expand All @@ -31,7 +31,7 @@ def handle_submission(ack, body, client, view, logger):
if len(errors) > 0:
ack(response_action="errors", errors=errors)
return
# Acknowledge the view_submission event and close the modal
# Acknowledge the view_submission request and close the modal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 21 in this file also says view_submission event. Same with line 10. Could you update these as well?

ack()
# Do whatever you want with the input data - here we're saving it to a DB
# then sending the user a verification of their submission
Expand Down
4 changes: 2 additions & 2 deletions docs/_basic/listening_responding_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ order: 9

<div class="section-content">

Your app can use the `command()` method to listen to incoming slash command events. The method requires a `command_name` of type `str`.
Your app can use the `command()` method to listen to incoming slash command requests. The method requires a `command_name` of type `str`.

Commands must be acknowledged with `ack()` to inform Slack your app has received the event.
Commands must be acknowledged with `ack()` to inform Slack your app has received the request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 10 in this file also uses events. Could you update that

incoming slash command events


There are two ways to respond to slash commands. The first way is to use `say()`, which accepts a string or JSON payload. The second is `respond()` which is a utility for the `response_url`. These are explained in more depth in the [responding to actions](#action-respond) section.

Expand Down
4 changes: 2 additions & 2 deletions docs/_basic/listening_responding_shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ order: 8

The `shortcut()` method supports both [global shortcuts](https://api.slack.com/interactivity/shortcuts/using#global_shortcuts) and [message shortcuts](https://api.slack.com/interactivity/shortcuts/using#message_shortcuts).

Shortcuts are invokable entry points to apps. Global shortcuts are available from within search and text composer area in Slack. Message shortcuts are available in the context menus of messages. Your app can use the `shortcut()` method to listen to incoming shortcut events. The method requires a `callback_id` parameter of type `str` or `re.Pattern`.
Shortcuts are invokable entry points to apps. Global shortcuts are available from within search and text composer area in Slack. Message shortcuts are available in the context menus of messages. Your app can use the `shortcut()` method to listen to incoming shortcut requests. The method requires a `callback_id` parameter of type `str` or `re.Pattern`.

Shortcuts must be acknowledged with `ack()` to inform Slack that your app has received the event.
Shortcuts must be acknowledged with `ack()` to inform Slack that your app has received the request.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update line 12 in this file to also use requests instead of events.

listen to incoming shortcut events


Shortcuts include a `trigger_id` which an app can use to [open a modal](#creating-modals) that confirms the action the user is taking.

Expand Down
2 changes: 1 addition & 1 deletion docs/_basic/responding_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ order: 6

<div class="section-content">

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 event took place.
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.

Expand Down