Skip to content

Commit 68ac4fe

Browse files
authored
Update lazy lambda docs (#524)
* Clarify lazy listener description * Update acknowledging requests
1 parent 068749a commit 68ac4fe

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

docs/_advanced/lazy_listener.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ order: 10
66
---
77

88
<div class="section-content">
9-
⚠️ 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.
9+
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.
1010

11-
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).
11+
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.
1212

13-
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.
13+
However, when running your app on FaaS or similar runtimes which **do not allow you to run threads or processes after returning an HTTP response**, we cannot follow the typical pattern of acknowledgement first, processing later. To work with these runtimes, set the `process_before_response` flag to `True`. When this flag is true, the Bolt framework holds off sending an HTTP response until all the things in a listener function are done. You need to complete your processing within 3 seconds or you will run into errors with Slack timeouts. Note that in the case of events, while the listener doesn't need to explicitly call the `ack()` method, it still needs to complete its function within 3 seconds as well.
1414

15-
Lazy listeners can be a solution for this issue. Rather than acting as a decorator, lazy listeners take two keyword args:
16-
* `ack: Callable`: Responsible for calling `ack()`
17-
* `lazy: List[Callable]`: Responsible for handling any time-consuming processes related to the request. The lazy function does not have access to `ack()`.
15+
To allow you to still run more time-consuming processes as part of your handler, we've added a lazy listener function mechanism. Rather than acting as a decorator, a lazy listener accepts two keyword args:
16+
* `ack: Callable`: Responsible for calling `ack()` within 3 seconds
17+
* `lazy: List[Callable]`: Responsible for handling time-consuming processes related to the request. The lazy function does not have access to `ack()`.
1818
</div>
1919

2020
```python
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ order: 7
77

88
<div class="section-content">
99

10-
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.
10+
Actions, commands, shortcuts, options requests, and view submissions must **always** be acknowledged using the `ack()` function. This lets Slack know that the request was received so that it may update the Slack user interface accordingly.
1111

12-
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).
12+
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). When acknowledging a view submission, you may supply a `response_action` as part of your acknowledge to update the view. Please see the relevant sections of the docs for more detail on options for `ack()` these different requests.
1313

14-
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.
14+
We recommend calling `ack()` right away before initiating any time-consuming processes such as fetching information from your database or sending a new message, since you only have 3 seconds to respond before Slack registers a timeout error.
1515

16+
💡 When working in a FaaS / serverless environment, our guidelines for when to `ack()` are different. See the section on **Lazy listeners (FaaS)** for more detail on this.
1617
</div>
1718

1819
<div>

0 commit comments

Comments
 (0)