https://github.com/pripoliveira50/daily-bot
📱 Daily Slack Notification is an automated Slack bot that schedules and announces daily stand-up meetings, informing the team about who will be presenting. It uses GitHub Actions for automatic execution and cron scheduling.
https://github.com/pripoliveira50/daily-bot
automation automation-tools cron-job cron-job-manager cron-job-schedule cron-jobs github-actions github-actions-ci python-script python3 slack slack-api slack-app slack-webhook slackbot
Last synced: 25 days ago
JSON representation
📱 Daily Slack Notification is an automated Slack bot that schedules and announces daily stand-up meetings, informing the team about who will be presenting. It uses GitHub Actions for automatic execution and cron scheduling.
- Host: GitHub
- URL: https://github.com/pripoliveira50/daily-bot
- Owner: pripoliveira50
- License: mit
- Created: 2025-02-28T18:29:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-26T15:04:30.000Z (about 1 year ago)
- Last Synced: 2025-06-26T18:45:09.685Z (11 months ago)
- Topics: automation, automation-tools, cron-job, cron-job-manager, cron-job-schedule, cron-jobs, github-actions, github-actions-ci, python-script, python3, slack, slack-api, slack-app, slack-webhook, slackbot
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 🤖 Daily Slack Notification – The Daily Assistant for Slack
The **Daily Slack Notification** is an automated bot for Slack that schedules and announces the daily stand-up meeting, highlighting who will be responsible for the day's presentation. 🚀
This bot creates an API in Slack using a Slack App with the necessary permissions to send messages to a specific channel.
---
## 📌 How to Create a Slack API for This Bot?
To use this bot, you will need to create a Slack App and get the required tokens. Follow the official Slack documentation:
🔗 [Create a Slack App](https://api.slack.com/apps)
The process is fully automated via GitHub Actions, allowing scheduled daily execution via cron jobs or manual execution whenever needed.
---
## 📌 Features
- ✅ Automatic daily announcement in Slack.
- ✅ Sequential selection of the presenter from the configured members.
- ✅ Correct mention of the presenter in Slack (using user IDs).
- ✅ Automated execution via GitHub Actions with scheduling (cron) support.
- ✅ Manual execution via GitHub Actions `workflow_dispatch`.
---
## 🛠 Technologies Used
This project was developed using:
- **Python 3.9**
- **GitHub Actions** (for execution automation)
- **Requests** (for integration with the Slack API)
---
## 📂 Project Structure
The project follows the structure below:
```
.
├── .github/workflows/ # GitHub Actions configuration
│ ├── ci.yaml # Workflow for automated execution
├── scripts/ # Directory for Python scripts
│ ├── daily_slack.py # Script responsible for sending messages to Slack
├── .gitignore # File to ignore unnecessary files in the repository
├── LICENSE # Project license
├── README.md # Project documentation
```
---
## 🔄 Presenter Selection Logic
The daily presenter is selected sequentially, ensuring a fair rotation among members.
### 📌 How Does It Work?
The script maintains a pre-configured list of team members (via `SLACK_MEMBERS`) and selects the next in line each day. When all members have presented, the order resets to the beginning.
---
### 🔹 Example:
If `SLACK_MEMBERS="U123456,U654321,U987654"`, the presentation order will be:
1️⃣ Day 1: U123456
2️⃣ Day 2: U654321
3️⃣ Day 3: U987654
4️⃣ Day 4: U123456 (restarts)
This logic ensures a fair rotation and prevents random selection.
---
## 🚀 Setup and Usage
### 1️⃣ Prerequisites
Before running the script, ensure you have:
- Python 3.9+ installed.
- A Slack bot configured with permissions to send messages.
- The following environment variables are configured in GitHub Actions:
| Variable | Description |
|------------------|--------------------------------------------|
| `SLACK_TOKEN` | Slack authentication token |
| `CHANNEL_ID` | ID of the channel where the message will be sent |
| `SLACK_MEMBERS` | List of member IDs for presentation, separated by commas |
💡 **How to get Slack user IDs?**
If you need user IDs, use the Slack API:
🔗 [Get Slack User List](https://api.slack.com/methods/users.list)
### 2️⃣ How to Run the Project Locally?
1️⃣ Clone the repository:
```sh
git clone https://github.com/your-username/daily-slack-notification.git
cd daily-slack-notification
```
2️⃣ Create and activate a virtual environment:
```sh
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
```
3️⃣ Install dependencies:
```sh
pip install -r requirements.txt
```
4️⃣ Set environment variables:
```sh
export SLACK_TOKEN="your_token_here"
export CHANNEL_ID="your_channel_id_here"
export SLACK_MEMBERS="U12345,U67890,U54321"
```
💡 On Windows, use:
```sh
set SLACK_TOKEN="your_token_here"
```
5️⃣ Run the script:
```sh
python scripts/daily_slack.py
```
---
## 📅 Scheduling via GitHub Actions
GitHub Actions allows bots to be automatically and manually executed.
### 🔹 Automatic Execution
The bot can be scheduled to run at specific times using cron jobs in GitHub Actions.
#### Example configuration (`.github/workflows/ci.yaml`):
```yaml
name: Daily Slack Notification
on:
schedule:
- cron: "30 12 * * 1-5" # Runs at 12:30 PM (UTC) Monday to Friday
workflow_dispatch: # Allows manual execution via GitHub Actions
jobs:
daily-slack-notification:
name: Send Slack Notification
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run Python script
run: python scripts/daily_slack.py
```
🔹 **Note:** The cron job can be adjusted to run at different times and days as needed.
---
## ✅ Testing and Debugging
If you need to test or debug the code:
1️⃣ Verify that environment variables are set correctly.
2️⃣ Test the Slack API manually using `requests.post`.
3️⃣ Use `print()` statements in the code to check variable values before sending the message.
---
## 🚨 Troubleshooting
- **The bot is not sending messages to Slack**
- Check if the `SLACK_TOKEN` is correct and active.
- Ensure the bot is present in the correct channel (`#your-channel`).
- **The bot is not running automatically**
- Confirm that GitHub Actions is enabled in the repository.
- Check the workflow history for possible errors.
---
## 🤝 How to Contribute
Please refer to our [Contribution Guide](CONTRIBUTING.md) to learn how to contribute to the project.
---
## 📄 License
This project is under the MIT License.
💡 Developed to help agile teams keep their daily stand-ups organized! 🚀
---
🚀 Made with ❤️ by [Priscila Oliveira](https://github.com/pripoliveira50/)