A Cloudflare Worker that automatically updates your Slack status based on your Google Calendar work location. The worker checks your calendar events daily and sets your Slack status to "Working remotely" when you're working from home.
- Automatically checks Google Calendar events for work location
- Updates Slack status to "Working remotely" when working from home
- Sends notifications when work location is not set for scheduled events
- Runs daily at 8:00 AM via Cloudflare Cron
- Supports both office and home working locations
- Prevents duplicate status updates
This project was developed with the assistance of Cursor, and Large Language Models (LLMs). Their capabilities in code generation, debugging, and documentation were invaluable in creating this tool efficiently.
- A Google Calendar API project with OAuth 2.0 credentials
- A Slack workspace with appropriate API tokens
- Node.js and npm installed
- Wrangler CLI installed (
npm install -g wrangler
)
- Clone the repository:
git clone https://github.com/ulrikandersen/slack-status-updater.git
cd slack-status-updater
- Install dependencies:
npm install
-
Set up environment variables:
- Copy the example configuration file:
cp .dev.vars.example .dev.vars
- Edit
.dev.vars
with your actual credentials:GOOGLE_CLIENT_ID
: Your Google OAuth client IDGOOGLE_CLIENT_SECRET
: Your Google OAuth client secretGOOGLE_REFRESH_TOKEN
: Your Google OAuth refresh token (obtained viaget_token.ts
)SLACK_USER_TOKEN
: Your Slack user token (starts withxoxp-
)SLACK_BOT_TOKEN
: Your Slack bot token (starts withxoxb-
)SLACK_USER_ID
: Your Slack user ID
-
Get your Google OAuth refresh token:
- Make sure your
.dev.vars
file hasGOOGLE_CLIENT_ID
andGOOGLE_CLIENT_SECRET
set - Run the token generator:
npx ts-node get_token.ts
- Open the provided URL in your browser
- Authorize the application
- Copy the refresh token from the console output to your
.dev.vars
file
- Make sure your
- Start the development server:
wrangler dev
- Access the status endpoint:
- Open your browser and navigate to
http://localhost:8787/status
- This will trigger the status check manually
- Open your browser and navigate to
- Login to Cloudflare:
wrangler login
-
Set up your secrets in the Cloudflare dashboard:
- Go to https://dash.cloudflare.com
- Navigate to Workers & Pages
- Select your worker
- Go to Settings > Variables
- Add all the environment variables from your
.dev.vars
file
-
Deploy the worker:
wrangler deploy
The following environment variables are required:
Variable | Description |
---|---|
GOOGLE_CLIENT_ID |
Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
Google OAuth client secret |
GOOGLE_REFRESH_TOKEN |
Google OAuth refresh token |
SLACK_USER_TOKEN |
Slack user token (starts with xoxp- ) - used for setting status |
SLACK_BOT_TOKEN |
Slack bot token (starts with xoxb- ) - used for sending reminder message |
SLACK_USER_ID |
Your Slack user ID |
- The worker runs daily at 8:00 AM via Cloudflare Cron
- It checks your Google Calendar events for the current day
- If you have events scheduled:
- If your work location is set to "Home", it updates your Slack status to "Working remotely"
- If no work location is set, it sends you a Slack message to set your location
- The status is only updated if you don't already have a status set
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.