Skip to content

Conversation

@shaydewael
Copy link
Contributor

@shaydewael shaydewael commented Sep 24, 2020

This adds advanced concepts to the documentation. I'm still working through some of the explanations for sections based on my understanding, but the code is in a state that's ready for review

Live preview: https://shaydewael.github.io/bolt-python/concepts

Category (place an x in each of the [ ])

  • slack_bolt.App and/or its core components
  • slack_bolt.async_app.AsyncApp and/or its core components
  • Adapters in slack_bolt.adapter
  • Document pages under /docs
  • Others

Requirements (place an x in each [ ])

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

  • I've read and understood the Contributing Guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've run ./scripts/install_all_and_run_tests.sh after making the changes.

@shaydewael shaydewael marked this pull request as draft September 24, 2020 23:47
- **`user_id`** only when using `user_token`.
</div>

```python
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only sample I haven't run locally because I couldn't get the version with the authorize function added. I'm guessing there's some mistakes. I will test this code sample and fix it in the near future.

margin: 1em 0 0 33%;
padding-bottom: 2em;
font-size: 1em;
line-height: 1.5em;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's some funky line-height stuff happening. I don't know why this was ever 1.5 because that's not how other docs are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooof it's still doing it when it builds on github pages. I'll look into styling

Copy link
Contributor

Choose a reason for hiding this comment

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

@shaydewael Sorry, I didn't mention this but I made the changes. I'd like to address this line-spacing issue in the tutorial docs. I'm not sure why it doesn't happen to Bolt for JS. Can you adjust this or keep this change as-is?

The issue

Current

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooof it's still doing it when it builds on github pages. I'll look into styling

@shaydewael I have been observing the configuration of Jekyll in this project may have some issues. Sometimes I have to delete _site directory to completely refresh the pages.

Copy link
Contributor Author

@shaydewael shaydewael Sep 28, 2020

Choose a reason for hiding this comment

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

Hey Kaz - I changed a lot of styling stuff when I started messing around with this. One thing I learned - the stylesheet is being included from slack.dev rather than shaydewael.github.io. This is because it's using the url from the config file.

I added line numbers and adjusted spacing:
image

and the getting started page:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

This is great! Thanks a lot.

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2020

Codecov Report

Merging #104 into main will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage   90.03%   90.03%           
=======================================
  Files         135      135           
  Lines        3842     3842           
=======================================
  Hits         3459     3459           
  Misses        383      383           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de93088...a96518a. Read the comment docs.

@shaydewael shaydewael added the docs Improvements or additions to documentation label Sep 25, 2020
Copy link
Contributor

@seratch seratch left a comment

Choose a reason for hiding this comment

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

@shaydewael Thanks a lot for the amazing work! I really appreciate your efforts to polish the existing ones (including my English 🙏 ).


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 call ack() and handle the event in seperate threads or processes. For events that do not require acknowledgement, you can create the listener as you normally would.

Rather than acting as a decorator, lazy listeners take two keyword args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Then, we can mention why you should use lazy in the case. The original one says To deal with this possible timeout issue, you can use ackandlazy functions for a listener. but something similar is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this accurate now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it looks almost done. I added a suggestion above.

```python

# The open_modal shortcut opens a plain old modal
# The open_modal shortcut listens to a shortcut with the callback_id "open_modal"
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch 👍

shaydewael and others added 7 commits September 28, 2020 09:58
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
@shaydewael shaydewael marked this pull request as ready for review September 28, 2020 21:22
]

def authorize(enterprise_id, team_id, logger):
logger.info(f"{enterprise_id},{team_id}")
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this line


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).

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 in seperate threads or processes, though you still need to complete everything within 3 seconds. For events that do not require acknowledgement, you can create listeners as you normally would.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about changing this way? Technically, it uses a thread internally but the more important point here is that process_before_response guarantees the completion of all the processes in a listener. Also, please polish the sentence for Events API. (NOTE: this is not Bolt Python specific - Bolt JS has the same limitation)

Suggested change
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 in seperate threads or processes, though you still need to complete everything within 3 seconds. For events that do not require acknowledgement, you can create listeners as you normally would.
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 call ack() and handle the event in seperate threads or processes. For events that do not require acknowledgement, you can create the listener as you normally would.

Rather than acting as a decorator, lazy listeners take two keyword args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, it looks almost done. I added a suggestion above.

@seratch
Copy link
Contributor

seratch commented Sep 28, 2020

@shaydewael I left a few comments. Once you resolve those, we can merge these documents. Thanks for your amazing work here 👍

shaydewael and others added 8 commits September 28, 2020 14:36
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
@shaydewael shaydewael requested a review from seratch September 28, 2020 21:41
Copy link
Contributor

@seratch seratch left a comment

Choose a reason for hiding this comment

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

Thanks - all looks great. We can squash commits and merge now.

@shaydewael shaydewael merged commit 42fa6a9 into slackapi:main Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants