https://github.com/bigbuildbench/slackapi_bolt-python
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.1%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: BigBuildBench
- License: mit
- Language: Python
- Default Branch: master
- Size: 0 Bytes
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 8
- Releases: 0
Metadata Files
README.md
Bolt
for Python
A Python framework to build Slack apps in a flash with the latest platform features. Read the getting started guide and look at our code examples to learn how to build apps using Bolt. The Python module documents are available here.
Setup
```bash
Python 3.6+ required
python -m venv .venv source .venv/bin/activate
pip install -U pip pip install slack_bolt ```
Creating an app
Create a Bolt for Python app by calling a constructor, which is a top-level export. If you'd prefer, you can create an async app.
```python import logging logging.basicConfig(level=logging.DEBUG)
from slack_bolt import App
export SLACKSIGNINGSECRET=***
export SLACKBOTTOKEN=xoxb-***
app = App()
Add functionality here
if name == "main": app.start(3000) # POST http://localhost:3000/slack/events ```
Running an app
```bash export SLACKSIGNINGSECRET=*** export SLACKBOTTOKEN=xoxb-*** python app.py
in another terminal
ngrok http 3000 ```
Running a Socket Mode app
If you use Socket Mode for running your app, SocketModeHandler is available for it.
```python import os from slackbolt import App from slackbolt.adapter.socket_mode import SocketModeHandler
Install the Slack app and get xoxb- token in advance
app = App(token=os.environ["SLACKBOTTOKEN"])
Add functionality here
if name == "main": # Create an app-level token with connections:write scope handler = SocketModeHandler(app, os.environ["SLACKAPPTOKEN"]) handler.start() ```
Run the app this way:
```bash export SLACKAPPTOKEN=xapp-*** export SLACKBOTTOKEN=xoxb-*** python app.py
SLACKSIGNINGSECRET is not required
Running ngrok is not required
```
Listening for events
Apps typically react to a collection of incoming events, which can correspond to Events API events, actions, shortcuts, slash commands or options requests. For each type of request, there's a method to build a listener function.
```python
Listen for an action from a Block Kit element (buttons, select menus, date pickers, etc)
app.action(action_id)(fn)
Listen for dialog submissions
app.action({"callback_id": callbackId})(fn)
Listen for slash commands
app.command(command_name)(fn)
Listen for an event from the Events API
app.event(event_type)(fn)
Listen for a custom step execution from a workflow
app.function(callback_id)(fn)
Convenience method to listen to only message events using a string or re.Pattern
app.message([pattern ,])(fn)
Listen for options requests (from select menus with an external data source)
app.options(action_id)(fn)
Listen for a global or message shortcuts
app.shortcut(callback_id)(fn)
Listen for view_submission modal events
app.view(callback_id)(fn) ```
The recommended way to use these methods are decorators:
python
@app.event(event_type)
def handle_event(event):
pass
Making things happen
Most of the app's functionality will be inside listener functions (the fn parameters above). These functions are called with a set of arguments, each of which can be used in any order. If you'd like to access arguments off of a single object, you can use args, an slack_bolt.kwargs_injection.Args instance that contains all available arguments for that event.
| Argument | Description |
| :---: | :--- |
| body | Dictionary that contains the entire body of the request (superset of payload). Some accessory data is only available outside of the payload (such as trigger_id and authorizations).
| payload | Contents of the incoming event. The payload structure depends on the listener. For example, for an Events API event, payload will be the event type structure. For a block action, it will be the action from within the actions list. The payload dictionary is also accessible via the alias corresponding to the listener (message, event, action, shortcut, view, command, or options). For example, if you were building a message() listener, you could use the payload and message arguments interchangably. An easy way to understand what's in a payload is to log it. |
| context | Event context. This dictionary contains data about the event and app, such as the botId. Middleware can add additional context before the event is passed to listeners.
| ack | Function that must be called to acknowledge that your app received the incoming event. ack exists for all actions, shortcuts, view submissions, slash command and options requests. ack returns a promise that resolves when complete. Read more in Acknowledging events.
| respond | Utility function that responds to incoming events if it contains a response_url (shortcuts, actions, and slash commands).
| say | Utility function to send a message to the channel associated with the incoming event. This argument is only available when the listener is triggered for events that contain a channel_id (the most common being message events). say accepts simple strings (for plain-text messages) and dictionaries (for messages containing blocks).
| client | Web API client that uses the token associated with the event. For single-workspace installations, the token is provided to the constructor. For multi-workspace installations, the token is returned by using the OAuth library, or manually using the authorize function.
| logger | The built-in logging.Logger instance you can use in middleware/listeners.
| complete | Utility function used to signal the successful completion of a custom step execution. This tells Slack to proceed with the next steps in the workflow. This argument is only available with the .function and .action listener when handling custom workflow step executions.
| fail | Utility function used to signal that a custom step failed to complete. This tells Slack to stop the workflow execution. This argument is only available with the .function and .action listener when handling custom workflow step executions.
Creating an async app
If you'd prefer to build your app with asyncio, you can import the AIOHTTP library and call the AsyncApp constructor. Within async apps, you can use the async/await pattern.
```bash
Python 3.6+ required
python -m venv .venv source .venv/bin/activate
pip install -U pip
aiohttp is required
pip install slack_bolt aiohttp ```
In async apps, all middleware/listeners must be async functions. When calling utility methods (like ack and say) within these functions, it's required to use the await keyword.
```python
Import the async app instead of the regular one
from slackbolt.asyncapp import AsyncApp
app = AsyncApp()
@app.event("appmention") async def eventtest(body, say, logger): logger.info(body) await say("What's up?")
@app.command("/hello-bolt-python") async def command(ack, body, respond): await ack() await respond(f"Hi <@{body['user_id']}>!")
if name == "main": app.start(3000) ```
If you want to use another async Web framework (e.g., Sanic, FastAPI, Starlette), take a look at the built-in adapters and their examples.
- The Bolt app examples
- The built-in adapters Apps can be run the same way as the syncronous example above. If you'd prefer another async Web framework (e.g., Sanic, FastAPI, Starlette), take a look at the built-in adapters and their corresponding examples.
Getting Help
The documentation has more information on basic and advanced concepts for Bolt for Python. Also, all the Python module documents of this library are available here.
If you otherwise get stuck, we're here to help. The following are the best ways to get assistance working through your issue:
- Issue Tracker for questions, bug reports, feature requests, and general discussion related to Bolt for Python. Try searching for an existing issue before creating a new one.
- Email our developer support team:
support@slack.com
Owner
- Name: BigBuildBench
- Login: BigBuildBench
- Kind: organization
- Repositories: 1
- Profile: https://github.com/BigBuildBench
abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.
GitHub Events
Total
- Delete event: 4
- Issue comment event: 4
- Push event: 1
- Pull request event: 18
- Create event: 16
Last Year
- Delete event: 4
- Issue comment event: 4
- Push event: 1
- Pull request event: 18
- Create event: 16
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 0
- Total pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: 2 months
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.4
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 5
Past Year
- Issues: 0
- Pull requests: 5
- Average time to close issues: N/A
- Average time to close pull requests: 2 months
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.4
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 5
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (12)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v4 composite
- actions/setup-python v5 composite
- codecov/codecov-action v4 composite
- actions/checkout v4 composite
- actions/deploy-pages v4 composite
- actions/setup-node v4 composite
- actions/upload-pages-artifact v3 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/checkout v4 composite
- actions/setup-python v5 composite
- actions/stale v9.0.0 composite
- mysql 8
- python 3.8.5-slim-buster build
- python 3.11-alpine3.17 build
- tiangolo/uvicorn-gunicorn python3.8-slim build
- python 3.8.5-slim-buster build
- python 3.8.5-slim-buster build
- python 3.8.5-slim-buster build
- python 3.8.5-slim-buster build
- python 3.8.5-slim-buster build
- python 3.8.5-slim-buster build
- 1089 dependencies
- @docusaurus/module-type-aliases 3.5.2 development
- @docusaurus/types 3.5.2 development
- @docusaurus/core 3.5.2
- @docusaurus/plugin-client-redirects ^3.5.2
- @docusaurus/preset-classic 3.5.2
- @mdx-js/react ^3.0.0
- clsx ^2.0.0
- docusaurus-theme-github-codeblock ^2.0.2
- prism-react-renderer ^2.4.0
- react ^18.0.0
- react-dom ^18.0.0
- aiohttp >=3,<4 development
- aiohttp-devtools >=0.13,<0.14 development
- aiohttp >=3,<4
- uvicorn <1
- slack_sdk *
- slack_sdk *
- slack_sdk *
- bottle >=0.12,<1
- CherryPy >=18,<19
- Django >=3.2,<4
- slack-bolt >=1.7,<2
- aiohttp >=3,<4
- slack_bolt *
- slack_bolt *
- uvicorn <1
- aiohttp >=3,<4
- fastapi <1
- slack_bolt *
- Flask >=1.1
- gunicorn >=20
- slack_bolt *
- Flask >1
- slack_bolt *
- uWSGI >=2,<3
- aiohttp >=3,<4
- sanic >=20,<21
- slack_bolt *
- falcon >=2,<3
- gunicorn >=20,<21
- uvicorn *
- fastapi <1
- uvicorn <1
- Flask >1
- slack-bolt *
- Flask >=1.1,<2
- slack_bolt *
- Flask >1
- google-cloud-datastore >=2.1.0,<3
- slack_bolt *
- aiohttp >=3,<4
- slack_bolt *
- Flask >=1.1
- gunicorn >=20
- slack_bolt *
- aiohttp >=3,<4
- sanic >=20,<21
- slack_bolt *
- Flask >=1.1
- gunicorn >=20
- slack_bolt *
- pyramid >=1,<2
- sanic >=20,<21
- uvicorn <1
- Flask >1
- SQLAlchemy *
- slack_bolt >=0.6
- databases *
- sanic >=20,<21
- slack_bolt >=0.6
- uvicorn <1
- starlette >=0.13,<1
- uvicorn <1
- tornado >=6,<7
- gunicorn <23
- boddle >=0.2,<0.3 test
- docker >=5,<8 test
- moto >=3,<6 test
- sanic-testing >=0.7 test
- aiohttp >=3,<4
- websockets <14
- pytest-asyncio <1 test
- pytest-cov >=3,<6 test
- black ==24.8.0
- flake8 ==6.0.0
- mypy ==1.11.2
- slack_sdk >=3.26.0,<4