Add support for "sub apps"
See original GitHub issueWhen creating a large slack application it would be nice to be able to reuse components in a more pythonic way than what is possible right now.
A workaround is described in issue #236, but it requires passing the app
object around and manually wiring up things by registering and calling decorators as functions directly.
I suggest adding a feature much like include_router in FastAPI or add_typer in Typer.
This feature will let us create sub-apps in separate files or even separate packages, like plugins that can be published on pypi.org separately.
Here is a small example illustrating what I mean:
main.py
Here is our main app, where we add a plugin from a separate package
import os
from slack_bolt import App
from my_plugin import my_plugin
# Initializes your app with your bot token and signing secret
app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)
app.add_app(my_plugin)
my_plugin.py
A simple plugin that just creates a slack_bolt
app, but without any config
from slack_bolt import App
my_plugin = App()
@my_plugin.message("hello")
def message_hello(message, say):
say("Hello world")
Category
- slack_bolt.App and/or its core components
- slack_bolt.async_app.AsyncApp and/or its core components
- Adapters in slack_bolt.adapter
- Others
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Sub Apps - Bubble Docs
The feature can be found in Settings > Sub apps. There, you can create a sub app using the current app as the...
Read more >Add an app to Microsoft Teams
Add from Apps On the left side of Teams select Apps and search for your favorite app or browse the app categories to...
Read more >Add Sub K-1 4+ - App Store
Updated to support iOS12 - thank you for your patience. • A few other minor tweaks. • As time allows, I'd enjoy hearing...
Read more >'Desktop PWA Sub Apps' could help users install multiple ...
A new potential Chrome flag discovered by Chrome Story called 'Desktop PWA Sub Apps' may enable installed web applications to create ...
Read more >Add developer account users and manage permissions
Choose what permissions to apply to specific apps using the App permissions tab, or what permissions to apply to all apps in your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My main goal was to facilitate better code reuse, but most importantly better organization of large complex slack apps while still being able to use the
@app.*
decorators.Maybe a kind of proxy sub app object would make sense then, and
app.add_sub_app(my_plugin)
could then transfer what ever was defined on the sub app to the main app.The important part is that the
SubApp
should be able to use all the decorators fromApp
.Here’s what I came up with:
Usage: