Slack Bridge API is a Flask-based REST API designed for user management, email-based user search, and Slack message integration.
Currently, this API supports querying users and sending messages to users through a Slack bot.
Features such as file attachments (e.g., images), sending messages to multiple users via the bot, sending messages to a specific channel (similar to a webhook), and responding to bot commands are not yet implemented. You can continue to modify and update the API as needed to include these features.
If you find this helpful, please the "star"π to support further improvements.
- User Search: Fetch user details by email or retrieve all users.
- Health Check: Validate server status with a lightweight endpoint.
- Slack Message Integration: Send Slack messages to users via the Slack API.
slack_bridge
βββ settings.py
βββ wsgi.py
βββ token_generator.py
βββ service_config.py
βββ service_control.sh
βββ collect_slackusers.py
βββ collect_slackusers.sh
βββ requirements.txt
βββ app
βββ authentication.py
βββ exceptions.py
βββ generics.py
βββ logger.py
βββ route.py
βββ search.py
βββ sendmessage.py
βββ validators.py
βββ db
βββ keys.db
βββ users.db
βββ logs
βββ slack_bridge.app.validators.exceptions.log
To start using SlackBridge API:
Clone the repository:
git clone https://github.com/password123456/slackbridge-api.git
Install dependencies:
pip install -r requirements.txt
Endpoint: /api/v1/message/send
Method: POST
Description
- Sends a message to a specific Slack user.
- Sends the message via a
Slack Bot
. - The name of the sending
Bot
is the one configured in Slack. - The size of a single message must not exceed the limit defined by the
verify_params_length
decorator. - The request body format is
JSON
.
Headers:
Authorization: <API_TOKEN>
Content-Type: application/json
Body Parameters:
Name | Type | Description | Required |
---|---|---|---|
String |
Recipient's email address. The email format is validated by the verify_email_param_suffix decorator. |
Yes | |
message | String |
The text message to send. Must not exceed 4000 bytes . |
Yes |
{
"email": "[email protected]",
"message": "Hello Tony, Get Out!"
}
- Success (200):
{
"status": true,
"result": {
"email": "[email protected]",
"message": "Message sent successfully, 2024-08-27T12:00:00Z"
}
- Error (400):
{
"status": false,
"error": "Required fields are missing in the request body. Please check and try again."
}
Endpoint: /api/v1/users/search
Method: POST
Description
- Retrieves information about a specific Slack user.
- Returns the user's
email
,username
,display name
, andSlack member_id
. - Time-related data in the response body follows the
ISO 8601
format (YYYY-MM-DDTHH:MM:SSZ
). - Both the request and response body formats are in
JSON
.
Headers:
Authorization: <API_TOKEN>
Content-Type: application/json
Body Parameters:
Name | Type | Description | Required |
---|---|---|---|
String |
Recipient's email address. The email format is validated by the verify_email_param_suffix decorator. |
Yes |
{
"email": "[email protected]",
}
- Success (200):
{
"status": true,
"result": {
"datetime": "2024-11-22T10:09:14+09:00",
"real_name": "tony.stark",
"display_name": "stark",
"member_id": "U072E6GR1LM",
"user_email": "[email protected]"
}
}
- Error (404):
{
"status": false,
"message": "The specified user could not be found. Please check the input and try again."
}
Endpoint: /api/v1/users/all
Method: GET
Description
- Retrieves information about all Slack users.
- Returns the user's
email
,username
,display name
, andSlack member_id
. - Time-related data in the response body follows the
ISO 8601
format (YYYY-MM-DDTHH:MM:SSZ
). - Both the request and response body formats are in
JSON
.
Headers:
Authorization: <API_TOKEN>
Body Parameters:
None
GET /api/v1/users/all
- Success (200):
{
"status": true,
"message": [
{
"datetime": "2024-11-22T10:09:14+09:00",
"real_name": "tony.stark",
"display_name": "stark",
"member_id": "U072E6GR1LM",
"user_email": "[email protected]"
},
{
"datetime": "2024-11-22T10:09:14+09:00",
"real_name": "Happy.Hogan",
"display_name": "happy",
"member_id": "U092P6GRALM",
"user_email": "[email protected]"
},
{
"datetime": "2024-11-22T10:09:14+09:00",
"real_name": "Steve.Rogers",
"display_name": "steve",
"member_id": "U132E6BR1LM",
"user_email": "[email protected]"
}
]
}
The SlackBridge API uses standard HTTP response codes to indicate success or failure. Additional details are provided in the response body.
HTTP Code | Meaning | Example |
---|---|---|
200 | Success | The request was successful. |
400 | Bad Request | Invalid parameters were provided. |
401 | Unauthorized | Invalid or missing token. |
404 | Not Found | The resource could not be found. |
500 | Internal Server Error | An error occurred on the server. |
token_generator.py
simplifies the creation, encryption, decryption, and validation of API tokens using AES-GCM encryption
, ensuring high security and integrity. It is particularly useful for managing access keys with expiration and IP-based restrictions.
-
Secure Token Management:
Generates encrypted tokens, stores them in a database, and retrieves them securely. -
Expiration & IP Validation:
Tokens include metadata such as issuer, expiration time, and allowed IP addresses for access control. -
AES-GCM Encryption:
Ensures confidentiality and integrity using a 32-byte passphrase key and a 12-byte nonce.