This repository provides an AWS Lambda function-based integration between Everhour Time Off, Google Calendar, and Slack to streamline time-off management and reporting. The integration allows users to enable or disable various features to enhance their time-off tracking experience.
To learn more on how this integration helps with coordinating and managing team's time off, click here.
The integration offers the following features, all of which are enabled by default. However, you have the flexibility to disable specific features by configuring the environment variables:
-
Send Time-Off Report to Slack Channel: Enable this feature to automatically send time-off reports to a specified Slack channel. This ensures that team members are aware of each other's time-off schedules and can plan their work accordingly.
-
Daily Time-Off Report: By enabling this feature, you can receive a daily report summarizing all time-off requests for the day. This report helps managers and team members stay up-to-date with the current time-off schedule.
-
Weekly Time-Off Report: This feature enables the generation of a weekly report that provides an overview of all time-off requests submitted during the week. It helps team leads and HR personnel analyze time-off trends and plan resources accordingly.
-
Sync with Calendar: Enable this feature to synchronize time-off requests with your Google Calendar. When a time-off request is approved or updated in Everhour, it will automatically reflect in your calendar, ensuring that your schedule remains accurate and up-to-date.
The integration includes three scheduled Lambda functions that automate the generation and delivery of reports. These functions are configured in the serverless.yml file and are triggered at specific intervals using AWS CloudWatch Events.
- cronHandler:
- Handler:
index.run
- Event: Invoke Lambda function every 30 minutes
The cronHandler function is responsible for continuously monitoring and processing time-off events. It ensures that the integration stays up-to-date with any changes in time-off requests or settings.
- dailyReportHandler:
- Handler:
daily-report.run
- Event: Invoke Lambda function at 05:00 AM (UTC+0) every day
The dailyReportHandler function generates a daily report summarizing all time-off requests for the day. It runs once a day at a specified time and sends the report to the configured recipients.
- weeklyReportHandler:
- Handler:
weekly-report.run
- Event: Invoke Lambda function at 04:30 AM (UTC+0) every Sunday
The weeklyReportHandler function generates a weekly report that provides an overview of all time-off requests submitted during the week. It runs once a week on Sunday at a specified time and sends the report to the configured recipients.
These scheduled functions ensure that the time-off reports are generated and delivered automatically without manual intervention. You can modify the schedule timings by updating the corresponding cron expressions in the serverless.yml
file to suit your specific needs.
Here are the steps you should follow to get started on this project:
- Go to Google developer console.
- In the Google Cloud console, go to Menu menu > IAM & Admin > Create a Project.
- In the Project Name field, enter a descriptive name for your project.
- In the Location field, click Browse to display potential locations for your project. Then, click Select.
- Click Create. The console navigates to the Dashboard page and your project is created within a few minutes.
- In the Google Cloud console, enable the Google Calendar API.
- In the Google Cloud console, go to Menu menu > APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Click Application type > Desktop app.
- In the Name field, type a name for the credential. This name is only shown in the Google Cloud console.
- Click Create. The OAuth client created screen appears, showing your new Client ID and Client secret.
- Click OK. The newly created credential appears under OAuth 2.0 Client IDs.
- Save the downloaded JSON file as
credentials.json
, and move the file to your working directory.
- Create a new slack workspace or use an existing one.
- Go to api.slack.com and click on
Create New App
button. - Choose
From scratch
option. - Choose a name for your app and the workspace you want to create your slack app on.
- On the
left-side panel
, click onOAuth & Permissions
. - In the
Scopes
section, click onAdd an OAuth scope
ofBot Token Scopes
and add the following scopes:- channels:history
- channels:read
- chat:write
- im:history
- im: read
- On the
left-side panel
, click onOAuth & Permissions
and copyBot User OAuth Token
. - Add Bot in the channel you want to send the report.
- Go to app.everhour.com.
- On the
left-side panel
, click onSetting
. - On the
My profile
tab scroll down toApplication Access
and create a newAPI Token
.
These are the requirements for project deployment:
- Install
serverless
module via NPM:npm install -g serverless
. - Configure your AWS credentials.
- Clone the
main
branch of this repository. - Install node modules using
npm i
command. - Set the environment variables on
serverless.yml
based onserverless.example.yml
file.-
EVER_HOUR_API: The base URL for the Everhour API (https://api.everhour.com). This variable specifies the endpoint where the integration will communicate with Everhour to retrieve time-off events and make any necessary updates.
-
EVER_HOUR_TOKEN: Your Everhour API token. This token serves as an authentication credential, allowing the integration to access your Everhour account and perform actions on your behalf.
-
TIME_ZONE: The time zone to be used for the integration. This variable determines the time zone in which the time-off events and reports will be generated and synced.
-
SLACK_BOT_TOKEN: Your Slack bot token. If Slack integration is enabled, this token is used to authenticate the integration with your Slack workspace, allowing it to send notifications and reports to Slack channels.
-
REPORT_CHANNEL_ID: The ID of the Slack channel where time-off reports will be posted. This variable specifies the destination channel for the integration to share daily and weekly time-off reports.
-
CALENDAR_NAME: The name of the Google Calendar that will be synced with Everhour. This variable specifies the target calendar where time-off events will be added or updated.
-
ENABLE_SYNC_TIME_OFF_WITH_CALENDAR: A boolean value (true or false) indicating whether the integration should synchronize time-off events with the specified Google Calendar. If set to true, time-off events will be synced; if set to false, no synchronization will occur.
-
ENABLE_SLACK_TIME_OFF_REPORT_CHANNEL: A boolean value indicating whether the integration should post time-off reports to the designated Slack channel. If set to true, reports will be shared; if set to false, no reports will be sent to Slack.
-
ENABLE_DAILY_TIME_OFF_REPORT: A boolean value indicating whether the integration should generate and share a daily time-off report. If set to true, a daily report will be generated; if set to false, no daily the report will be created.
-
ENABLE_WEEKLY_TIME_OFF_REPORT: A boolean value indicating whether the integration should generate and share a weekly time-off report. A weekly report will be generated; if set to false, no weekly report will be created.
-
- Deploy the project by running:
serverless deploy
It's required to follow the steps below, to run the services and the project:
- Install node modules using
npm i
command. - Set the environment variables on
serverless.yml
based onserverless.example.yml
file. - In order to test out your functions locally, you can invoke them with the following command:
serverless invoke local --function cronHandler
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. Feel free to use, modify, and distribute the code for both commercial and non-commercial purposes.