Automatically update your Slack status based on your work schedule, breaks, and holidays using Google Apps Script and Slack API.
MIT License
日本語版の説明はこちら - Japanese version here (Qiita)
Automatically update your Slack status based on your work schedule, breaks, and holidays using Google Apps Script and Slack API.
users.profile:write
, users:write
USER_TOKEN
and paste your Slack API token as the valueThis script can be easily customized to fit your specific location, work schedule, and holidays. Here's how you can modify these settings:
slackStatusUpdater.gs
file.VACATION_PERIODS
object in the CONSTANTS
.VACATION_PERIODS: {
NEW_YEARS: { start: '01-01', end: '01-01', name: "New Year's Day", emoji: '🎉' },
MARTIN_LUTHER_KING: { start: '01-17', end: '01-17', name: "Martin Luther King Jr. Day", emoji: '✊🏾' },
PRESIDENTS_DAY: { start: '02-21', end: '02-21', name: "Presidents' Day", emoji: '🇺🇸' },
...
},
Find the checkVacationPeriod
function in the script.
Locate the following line:
const formattedDate = Utilities.formatDate(date, 'America/San_Francisco', 'MM-dd');
Replace 'America/San_Francisco' with your desired time zone. For example:
You can find a full list of supported time zones in the IANA Time Zone Database.
In the CONSTANTS
object, find the WORK_HOURS
section.
Modify the values to match your work schedule. For example:
WORK_HOURS: {
START: 9, // Work starts at 9 AM
END: 17, // Work ends at 5 PM
LUNCH_START: 12,
LUNCH_END: 13,
BREAK_START: 15,
BREAK_END: 15.25, // 15 minutes break
},
In the CONSTANTS object, locate the STATUSES and EMOJIS sections. Modify the text and emojis to your preference:
STATUSES: {
DEFAULT: { presence: 'auto', text: '', emoji: '' },
OUTSIDE_WORK: { presence: 'away', text: '', emoji: '' },
HOLIDAY: { presence: 'away', text: 'Holiday', emojiType: 'HOLIDAY' },
LUNCH: { presence: 'away', text: 'Lunch Break', emojiType: 'LUNCH' },
BREAK: { presence: 'auto', text: 'Short Break', emojiType: 'BREAK' },
},
EMOJIS: {
HOLIDAY: ['🌴', '🏔️', '🏖️', '📖', '🎮'],
LUNCH: ['🍱', '🍛', '🍜', '🍝', '🍣', '🍙', '🍔', '🥪', '🥗', '🍕'],
BREAK: ['☕', '🍵', '🥤', '🍡', '🍩'],
},
Remember to save your changes after customization. These modifications will allow you to tailor the script to your specific needs, location, and work culture.
updateUserStatus
function manually to test the scriptupdateUserStatus
as the function to runContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This script interacts with the Slack API. Please be aware of Slack's API usage limits and terms of service when using this script.