A Node.js script that automatically fetches time tracking data from Clockify API and sends formatted daily updates to Slack using simple text messages.
- Clockify Integration: Fetches time entries and project data from Clockify API
- Project Grouping: Groups tasks by project for better organization
- Date Filtering: Only sends today's updates (or custom date)
- Simple Text Format: Clean, readable text messages (no complex blocks)
- Environment Configuration: Secure credential management
- Error Handling: Comprehensive error handling and logging
git clone <your-repo>
cd slack-updates
npm install
Copy the example environment file and fill in your credentials:
cp .env.example .env
Edit .env
with your actual values:
# Clockify API Configuration
CLOCKIFY_API_KEY=your_clockify_api_key
CLOCKIFY_USER_ID=your_user_id
CLOCKIFY_WORKSPACE_ID=your_workspace_id
# Slack Configuration
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
SLACK_CHANNEL=#daily-updates
SLACK_BOT_NAME=Daily Update Bot
SLACK_BOT_ICON=:memo:
# Test Clockify connection
npm run test:connection
# Test Slack webhook
npm run test:slack
# Test full functionality
npm test
npm start
Daily Update:
ReqMe:
Fix editor spacing issue in company description field and update readme with the latest environment configuration details in both frontend and backend
Update tags in wordpress SVN to 1.0.0 for plugin
Update the SOW for deals flow according to Yashua's feedback
-
Get API Key:
- Go to Clockify → Profile → API → Generate API Key
-
Find User ID:
- Go to Clockify → Profile → Copy User ID
-
Find Workspace ID:
- Go to Clockify → Workspace Settings → Copy Workspace ID
-
Create Webhook:
- Go to Slack App → Your Apps → Create New App
- Add "Incoming Webhooks" feature
- Create webhook for your channel
- Copy webhook URL
-
Configure Channel:
- Set
SLACK_CHANNEL
to your target channel (e.g.,#daily-updates
)
- Set
Edit config.js
:
DATE_FILTER: {
USE_TODAY: true, // Set to false for custom date
CUSTOM_DATE: "2025-07-30" // Use when USE_TODAY is false
}
Edit the createSlackMessage
function in slack-daily-update.js
:
function createSlackMessage(entries, projects) {
let message = `${config.MESSAGE.HEADER}:\n`;
// Customize your message format here
}
To include user names in the output, modify the grouping logic:
// In createSlackMessage function
entries.forEach((entry) => {
const projectId = entry.projectId;
const projectName = getProjectName(projectId, projects);
const userName = getUserName(entry.userId, users); // Add user lookup
const key = `${projectName} - ${userName}`;
// ... rest of the logic
});
npm run test:connection
npm run test:slack
npm test
This will show you exactly what the message will look like without sending it to Slack.
-
401 Unauthorized:
- Check your
CLOCKIFY_API_KEY
- Verify the API key is active
- Check your
-
404 Not Found:
- Verify
CLOCKIFY_WORKSPACE_ID
andCLOCKIFY_USER_ID
- Check if the workspace/user exists
- Verify
-
No entries found:
- Check if you have time entries for the target date
- Verify the date format and timezone
-
Slack webhook errors:
- Verify your webhook URL is correct
- Check if the webhook is still active
- Ensure the channel exists and the bot has access
The script includes detailed logging. Check the console output for:
- API request details
- Response data
- Message format preview
- Error details
Add to your crontab:
# Run daily at 5:00 PM
0 17 * * * cd /path/to/slack-updates && npm start
- Open Task Scheduler
- Create Basic Task
- Set trigger to daily at 5:00 PM
- Set action to start program:
node
- Add arguments:
slack-daily-update.js
- Set start in:
/path/to/slack-updates
GET /workspaces/{workspaceId}/projects
- Fetch projectsGET /workspaces/{workspaceId}/user/{userId}/time-entries
- Fetch time entries
MIT License - feel free to use and modify as needed.