A Slack bot that announces weekly events from Factorial calendar, including birthdays, anniversaries, leaves, holidays, and new employee first days.
- New Employee Announcements: Welcomes new team members on their first day
- Birthday Notifications: Celebrates team member birthdays
- Company Anniversary Reminders: Recognizes employees' work anniversaries
- Leave Notifications: Informs about team members on leave
- Holiday Announcements: Displays public holidays
- Node.js (v14 or higher recommended)
- A Slack workspace with admin permissions
- Factorial account with calendar access
- Clone the repository:
git clone https://github.com/weorbitant/factorial-calendar-slack.git
cd factorial-calendar-slack- Install dependencies:
npm install- Create a
.envfile based on.env.example:
cp .env.example .env- Configure your environment variables (see Configuration section below)
-
Go to Slack API Apps
-
Create a new app or select an existing one
-
Enable Socket Mode:
- Go to "Socket Mode" in the sidebar
- Enable Socket Mode
- Generate an App-Level Token with
connections:writescope - Copy the token (starts with
xapp-) toSLACK_APP_TOKEN
-
Configure OAuth & Permissions:
- Go to "OAuth & Permissions" in the sidebar
- Add the following Bot Token Scopes:
chat:writechannels:read
- Install the app to your workspace
- Copy the Bot User OAuth Token (starts with
xoxb-) toSLACK_BOT_TOKEN
-
Get your channel ID:
- Right-click on the target Slack channel
- Select "View channel details"
- Copy the Channel ID from the bottom of the modal
- Add it to
SLACK_CHANNEL_ID
- Log in to your Factorial account
- Navigate to the calendar section
- Find the calendar export/subscription option
- Copy the iCal feed URL (should end with
.ics) - Add the URL to
FACTORIAL_CALENDAR_URLin your.envfile
| Variable | Description | Example |
|---|---|---|
SLACK_APP_TOKEN |
Slack App-Level Token | xapp-1-XXXXXXXXXXXXX-... |
SLACK_BOT_TOKEN |
Slack Bot User OAuth Token | xoxb-XXXXXXXXXXXXX-... |
SLACK_CHANNEL_ID |
Target Slack channel ID | C01XXXXXXXX |
FACTORIAL_CALENDAR_URL |
Factorial calendar iCal feed URL | https://api.factorialhr.com/calendars/... |
Run the application:
node app.jsThe bot will:
- Fetch events from the Factorial calendar
- Organize events by category
- Post a formatted message to the configured Slack channel
The bot categorizes events based on patterns defined in config.js:
- First Day:
"Primer día de %s en la empresa" - Birthday:
"🎉 Cumpleaños de %s" - 1st Anniversary:
"🎉 Primer aniversario de %s en la empresa" - Multiple Years Anniversary:
"🎉 %d aniversario de %s en la empresa" - Leave:
"%s: ausente durante %d días" - Holidays: Any event that doesn't match the above patterns
You can customize these patterns in the config.js file to match your Factorial calendar event naming conventions.
factorial-calendar-slack/
├── app.js # Main application logic
├── config.js # Event matcher patterns configuration
├── package.json # Project dependencies and metadata
├── .env # Environment variables (not in repo)
├── .env.example # Environment variables template
└── README.md # This file
- Calendar Fetching: The app fetches the iCal feed from Factorial using
node-ical - Event Processing: Events are filtered for the current and next week
- Categorization: Events are organized by type using regex pattern matching
- Slack Integration: A formatted message is sent to Slack using the Web API and Socket Mode
fetchCalendar(): Retrieves and parses the Factorial calendarfindThisWeeksEvents(): Filters events for the current weekfindNextWeeksEvents(): Filters events for the next weekorganizeEvents(): Categorizes events based on config matcherspatternToRegex(): Converts config patterns to regex (supports%sfor strings,%dfor digits)extractEventData(): Extracts relevant data (names, years, days) from event summaries
To run this bot automatically on a schedule, consider using:
-
Cron jobs (Linux/Mac):
# Run every Monday at 9 AM 0 9 * * 1 cd /path/to/factorial-calendar-slack && node app.js
-
Task Scheduler (Windows)
-
Cloud schedulers: AWS EventBridge, Google Cloud Scheduler, Azure Logic Apps
-
Process managers: PM2 with cron mode
-
Bot not posting messages:
- Verify the bot is invited to the target channel
- Check that
SLACK_CHANNEL_IDis correct - Ensure bot has
chat:writepermission
-
Calendar not loading:
- Verify
FACTORIAL_CALENDAR_URLis accessible - Check if the URL requires authentication
- Ensure the URL points to a valid
.icsfile
- Verify
-
Events not being categorized:
- Review event summaries in Factorial
- Adjust patterns in
config.jsto match your event naming - Check console output for unmatched events
Contributions are welcome! Please feel free to submit a Pull Request.
ISC
Jose Vicente Giner (GentooXativa)
For issues and questions, please open an issue at: https://github.com/weorbitant/factorial-calendar-slack/issues