Skip to content
Open
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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,19 @@ Most of the app's functionality will be inside listener functions (the `fn` para

## Creating an async app

If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can import the [AIOHTTP](https://docs.aiohttp.org/en/stable/) library and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can install the async extra to include [AIOHTTP](https://docs.aiohttp.org/en/stable/) and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.

```bash
# Python 3.7+ required
# Python 3.9+ required for the async extra
python -m venv .venv
source .venv/bin/activate

pip install -U pip
# aiohttp is required
pip install slack_bolt aiohttp
pip install "slack_bolt[async]"
```

If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.

In async apps, all middleware/listeners must be async functions. When calling utility methods (like `ack` and `say`) within these functions, it's required to use the `await` keyword.

```python
Expand Down
4 changes: 2 additions & 2 deletions docs/english/concepts/async.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Using async (asyncio)

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](https://docs.aiohttp.org) to make API requests. On Python 3.9 and newer, install the async extra by running `pip install "slack_bolt[async]"`. If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.

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
# Requirement: pip install "slack_bolt[async]"
from slack_bolt.async_app import AsyncApp
app = AsyncApp()

Expand Down
4 changes: 2 additions & 2 deletions docs/japanese/concepts/async.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Async(asyncio)の使用

非同期バージョンの Bolt を使用する場合は、`App` の代わりに `AsyncApp` インスタンスをインポートして初期化します。`AsyncApp` では [AIOHTTP](https://docs.aiohttp.org/) を使って API リクエストを行うため、`aiohttp` をインストールする必要があります(`requirements.txt` に追記するか、`pip install aiohttp` を実行します)
非同期バージョンの Bolt を使用する場合は、`App` の代わりに `AsyncApp` インスタンスをインポートして初期化します。`AsyncApp` では [AIOHTTP](https://docs.aiohttp.org/) を使って API リクエストを行います。Python 3.9 以降では、`pip install "slack_bolt[async]"` を実行して async extra をインストールしてください。Python 3.7 または 3.8 を使用している場合は、その Python ランタイムと互換性のある `aiohttp` のバージョンを別途インストールしてください

非同期バージョンのプロジェクトのサンプルは、リポジトリの [`examples` フォルダ](https://github.com/slackapi/bolt-python/tree/main/examples)にあります。

```python
# aiohttp のインストールが必要です
# 必要条件: pip install "slack_bolt[async]"
from slack_bolt.async_app import AsyncApp
app = AsyncApp()

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "slack_bolt"
dynamic = ["version", "readme", "authors"]
dynamic = ["version", "readme", "authors", "optional-dependencies"]
description = "The Bolt Framework for Python"
license = { text = "MIT" }
classifiers = [
Expand Down Expand Up @@ -34,6 +34,7 @@ include = ["slack_bolt*"]
[tool.setuptools.dynamic]
version = { attr = "slack_bolt.version.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }
optional-dependencies.async = { file = ["requirements/async.txt"] }

[tool.distutils.bdist_wheel]
universal = true
Expand Down
2 changes: 2 additions & 0 deletions requirements/async.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pip install -r requirements/async.txt
aiohttp>=3,<4; python_version >= "3.9"
9 changes: 5 additions & 4 deletions slack_bolt/async_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

### Creating an async app

If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can import the [AIOHTTP](https://docs.aiohttp.org/en/stable/) library and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can install the async extra to include [AIOHTTP](https://docs.aiohttp.org/en/stable/) and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.

```bash
# Python 3.7+ required
# Python 3.9+ required for the async extra
python -m venv .venv
source .venv/bin/activate

pip install -U pip
# aiohttp is required
pip install slack_bolt aiohttp
pip install "slack_bolt[async]"
```

If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.

In async apps, all middleware/listeners must be async functions. When calling utility methods (like `ack` and `say`) within these functions, it's required to use the `await` keyword.

```python
Expand Down