Skip to content

Commit 67e0286

Browse files
committed
Tweak lazy listener function docs
1 parent 9ab7dd5 commit 67e0286

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/_advanced/lazy_listener.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Lazy listeners can be a solution for this issue. Rather than acting as a decorat
1919

2020
```python
2121
def respond_to_slack_within_3_seconds(body, ack):
22-
if body.get("text") is None:
22+
text = body.get("text")
23+
if text is None or len(text) == 0:
2324
ack(f":x: Usage: /start-process (description here)")
2425
else:
2526
ack(f"Accepted! (task: {body['text']})")
@@ -43,7 +44,7 @@ app.command("/start-process")(
4344
</summary>
4445

4546
<div class="secondary-content" markdown="0">
46-
This example deploys the code to [AWS Lambda](https://aws.amazon.com/lambda/). There are more examples within the [`sample` folder](https://github.com/slackapi/bolt-python/tree/main/adapter).
47+
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).
4748

4849
```bash
4950
pip install slack_bolt
@@ -63,11 +64,14 @@ lambda deploy --config-file config.yaml --requirements requirements.txt
6364

6465
```python
6566
from slack_bolt import App
67+
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
68+
6669
# process_before_response must be True when running on FaaS
6770
app = App(process_before_response=True)
6871

6972
def respond_to_slack_within_3_seconds(body, ack):
70-
if "text" in body:
73+
text = body.get("text")
74+
if text is None or len(text) == 0:
7175
ack(":x: Usage: /start-process (description here)")
7276
else:
7377
ack(f"Accepted! (task: {body['text']})")
@@ -82,7 +86,6 @@ app.command("/start-process")(
8286
lazy=[run_long_process] # unable to call `ack()` / can have multiple functions
8387
)
8488

85-
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
8689
def handler(event, context):
8790
slack_handler = SlackRequestHandler(app=app)
8891
return slack_handler.handle(event, context)

0 commit comments

Comments
 (0)