Add custom function support
This PR includes all the changes from #986 aims to add support for custom functions in Bolt Python
Feedback
I'm looking for feedback on
- Usability, is this what we envisioned the developer experience would be?
- Does this aline with the Bolt-js experience?
- Implementation, does this implementation align with bolt principles
- Tests, is this missing tests that could be valuable for the feature
Testing
This gist was created to show how to test these new feature, use it with the following steps
- Create a new app a. Head to https://api.slack.com/apps/?new_app=1 b. Click "From an app manifest" c. Select YAML and paste the above manifest.yml content d. Click create button
- Install the app into org/workspace
a. Install the app anyways (when the workspace is in an Org, org-wide installation is required to publish functions)
b. Grab the xoxb- token (Settings > Install App > Bot User OAuth Token)
c.
export SLACK_BOT_TOKEN=xoxb-... - Set up Socket Mode
a. Head to Settings > Basic Information > App-Level Tokens on the https://api.slack.com/apps page
b. Generate a new token with connections:write scope
c.
export SLACK_APP_TOKEN=xapp-... - Spin up the app
a. Add
app.pyandasync_app.pywith the above source code b. Pull the latest PR branch of bolt python to your local c. Runscripts/build_pypi_package.shthis will generate a.whlin thedist/folder d. (Optional) In your project set up a venv withpython -m venv .venvandsource .venv/bin/activatee.pip install global/path/to/bolt-python/dist/something.whlf.pip install aiohttpgpython app.pyorpython async_app.py - Add the custom step to a workflow a. Open the workflow builder b. Create a new workflow with a link trigger d. Seach "Hello" in the Steps view on the right side e. Add the step to the workflow (you can set any user ID as the input) f. Publish the workflow
Category
- [x]
slack_bolt.Appand/or its core components - [x]
slack_bolt.async_app.AsyncAppand/or its core components - [ ] Adapters in
slack_bolt.adapter - [ ] Document pages under
/docs - [ ] Others
Requirements
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
- [x] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [x] I've run
./scripts/install_all_and_run_tests.shafter making the changes.
Codecov Report
Attention: Patch coverage is 98.49246% with 3 lines in your changes missing coverage. Please review.
Project coverage is 92.00%. Comparing base (
fbd6462) to head (cd82e9a). Report is 1 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| slack_bolt/request/internals.py | 93.10% | 2 Missing :warning: |
| slack_bolt/context/base_context.py | 90.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1021 +/- ##
==========================================
+ Coverage 91.80% 92.00% +0.19%
==========================================
Files 186 195 +9
Lines 6408 6605 +197
==========================================
+ Hits 5883 6077 +194
- Misses 525 528 +3
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@seratch @WilliamBergamin When will this PR be merged?
@sharvesh06 yess this PR will be merged soon!