The Bolt Framework for Python
Project description
⚠️ Important Notice ⚠️
🔄 Still Work In Progress 🔄
This project is still in alpha, and may have bugs in it. Also, the public APIs can be changed until the v1 release. We are keen to hear your feedback. Please feel free to submit an issue!
Bolt for Python (still in alpha)
A Python framework to build Slack apps in a flash with the latest platform features. Check the samples to know how to use this framework.
Setup
python -m venv env
source env/bin/activate
pip install slack_bolt
First Bolt App (app.py)
Create an app by calling a constructor, which is a top-level export.
import logging
logging.basicConfig(level=logging.DEBUG)
from slack_bolt import App
# export SLACK_SIGNING_SECRET=***
# export SLACK_BOT_TOKEN=xoxb-***
app = App()
# Middleware
@app.middleware # or app.use(log_request)
def log_request(logger, payload, next):
logger.info(payload)
return next()
# Events API: https://api.slack.com/events-api
@app.event("app_mention")
def event_test(say):
say("What's up?")
# Interactivity: https://api.slack.com/interactivity
@app.shortcut("callback-id-here")
# @app.command("/hello-bolt-python")
def open_modal(ack, client, logger, payload):
# acknowledge the incoming request from Slack immediately
ack()
# open a modal
api_response = client.views_open(
trigger_id=payload["trigger_id"],
view={
"type": "modal",
"callback_id": "view-id",
"title": {
"type": "plain_text",
"text": "My App",
},
"submit": {
"type": "plain_text",
"text": "Submit",
},
"blocks": [
{
"type": "input",
"block_id": "b",
"element": {
"type": "plain_text_input",
"action_id": "a"
},
"label": {
"type": "plain_text",
"text": "Label",
}
}
]
})
logger.debug(api_response)
@app.view("view-id")
def view_submission(ack, payload, logger):
ack()
# Prints {'b': {'a': {'type': 'plain_text_input', 'value': 'Your Input'}}}
logger.info(payload["view"]["state"]["values"])
if __name__ == "__main__":
app.start(3000) # POST http://localhost:3000/slack/events
Run the Bolt App
export SLACK_SIGNING_SECRET=***
export SLACK_BOT_TOKEN=xoxb-***
python app.py
# in another terminal
ngrok http 3000
Feedback
We are keen to hear your feedback. Please feel free to submit an issue!
License
The MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slack_bolt-0.3.2a0.tar.gz.
File metadata
- Download URL: slack_bolt-0.3.2a0.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7285253ee0b1b8698dfb19e6d464b36e5faa960be59327dbf1b8c7435850e06
|
|
| MD5 |
2c30403d11b1546c03382aed31d3c868
|
|
| BLAKE2b-256 |
9f700cba889cdd8634ed746e181b236cbfc5a0a2a32246db65e23b33f0eabf70
|
File details
Details for the file slack_bolt-0.3.2a0-py2.py3-none-any.whl.
File metadata
- Download URL: slack_bolt-0.3.2a0-py2.py3-none-any.whl
- Upload date:
- Size: 91.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dbf820f18636aa47140715ac2405bd21eed87c81634dbcb93eeda27e29ba3ba
|
|
| MD5 |
98baf6a5d76b07906a017b9221bf9fe4
|
|
| BLAKE2b-256 |
cdb8e08aa9ec05a75b889b05d5208f0a85f76823d574ef9b3e6c6501968e92fd
|