slackapi / bolt-python

A framework to build Slack apps using Python
https://tools.slack.dev/bolt-python/
MIT License
1.07k stars 245 forks source link

Flask Blueprints / App factory example #930

Closed CodeHostedHere closed 1 year ago

CodeHostedHere commented 1 year ago

Is there any example of bolt sdk with flask blueprints and app factory pattern? I'm looking to integrate bolt with a slack app I'm making but it starts correctly and never triggers.

Init here https://github.com/CodeHostedHere/channel_response_bot/blob/glacey/bolt-api/app/__init__.py

Put it in this controller https://github.com/CodeHostedHere/channel_response_bot/blob/glacey/bolt-api/app/messages/controllers.py

but it won't say Hi back :)

The page URLs

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.

seratch commented 1 year ago

Hi @CodeHostedHere, thanks for writing in!

As for the Request URLs to handle events/slash command requests from the Slack API server, we recommend using a single endpoint for handling them. You can create a singleton slack_bolt.App instance and register all the listener functions to it, and then use the Flask adapter to handle requests in the Request URL route.

You can still use Flask's blueprints for other parts of your web app. However, there is no benefit to using them for the Bolt app part of your app. If you want to split your Bolt app into smaller source files, we recommend using our project template found here: https://github.com/slack-samples/bolt-python-starter-template.

I hope this helps.

CodeHostedHere commented 1 year ago

Thank you!