Slack Work Arrangement Integration Setup Guide
This guide will help you set up the Slack integration for tracking work-from-home arrangements via emoji reactions.
Overviewā
The work arrangement tracking system allows team members to indicate where they're working from (home, main office, or alternate office) by reacting to a daily Slack message with specific emojis. The system tracks quota usage (e.g., once per week for working from home) and provides an admin dashboard to view arrangements.
Featuresā
- š± Track work locations via Slack emoji reactions
- š Quota management (configurable limit per week)
- š Admin dashboard to view arrangements and quota status
- š Real-time tracking via Slack webhooks
- š„ Team-wide visibility
Setup Stepsā
1. Create a Slack Appā
- Go to Slack API
- Click Create New App ā From scratch
- Name your app (e.g., "Work Arrangement Tracker")
- Select your workspace
2. Configure Bot Permissionsā
Navigate to OAuth & Permissions and add the following Bot Token Scopes:
channels:history- Read messages in public channelsreactions:read- View emoji reactions and their associated contentusers:read- View people in the workspacechat:write- Post messages
3. Enable Event Subscriptionsā
-
Go to Event Subscriptions
-
Enable Events: ON
-
Set Request URL to:
https://your-domain.com/api/slack/events- Replace
your-domain.comwith your actual domain - Slack will verify the URL is working
- Replace
-
Subscribe to the following bot events:
reaction_added- A member added an emoji reactionreaction_removed(optional) - A member removed an emoji reaction
-
Click Save Changes
4. Install App to Workspaceā
- Go to Install App
- Click Install to Workspace
- Review permissions and authorize
- Copy the Bot User OAuth Token (starts with
xoxb-)
5. Get Signing Secretā
- Go to Basic Information
- Find App Credentials section
- Copy the Signing Secret
6. Get Channel IDā
- Open Slack and navigate to the channel where daily messages will be posted
- Right-click the channel name ā View channel details
- Scroll down to find the Channel ID
- Or use the Slack API: https://api.slack.com/methods/conversations.list
7. Configure Environment Variablesā
Add the following to your .env.local file:
# Slack Work Arrangement Integration
SLACK_BOT_TOKEN=xoxb-your-bot-token-here
SLACK_SIGNING_SECRET=your-signing-secret-here
SLACK_CHANNEL_ID=C01234ABCDE
8. Initialize Slack Configurationā
Use the API to configure the Slack integration:
curl -X POST https://your-domain.com/api/slack/config \
-H "Content-Type: application/json" \
-d '{
"botToken": "xoxb-your-bot-token",
"signingSecret": "your-signing-secret",
"channelId": "C01234ABCDE",
"dailyMessageTime": "09:00",
"enabled": true,
"emojiMapping": {
"home": "š ",
"main_office": "š¢",
"alternate_office": "šļø"
},
"quotaSettings": {
"homeQuotaPerWeek": 1,
"weekStartsOn": 1
},
"updatedBy": "admin"
}'
9. Map People to Slack Usersā
Update your people (staff) records in Firestore to include their Slack user IDs:
// Get Slack user ID from their profile or API
// Update person document (people collection)
await db.collection('people').doc(personId).update({
slackUserId: 'U01234ABCDE'
});
You can find Slack user IDs:
- From their profile: Click profile ā More ā Copy member ID
- Via API: https://api.slack.com/methods/users.list
Usageā
Daily Workflowā
-
Post Daily Message: Every morning, post a message in your configured channel asking team members where they'll be working
Example message:
Good morning team! š
Where are you working from today?
React with:
š - Working from home
š¢ - Main office
šļø - Alternate office -
Team Members React: Team members react to the message with the appropriate emoji
-
Automatic Tracking: The system automatically records their work arrangement and updates quota information
-
View Dashboard: Admins can view arrangements at
/work-arrangements
Emoji Configurationā
Default emojis (configurable):
- š (
:house:) - Home - š¢ (
:office:) - Main Office - šļø (
:classical_building:) - Alternate Office
You can customize these emojis in the Slack configuration.
Quota Settingsā
- homeQuotaPerWeek: Number of times an engineer can work from home per week (default: 1)
- weekStartsOn: Day of week that starts the week (0 = Sunday, 1 = Monday, etc.)
When an engineer exceeds their quota, the system logs a warning (you can extend this to send Slack DMs).
Admin Dashboardā
Access the dashboard at: /work-arrangements
Features:ā
- View Arrangements: See who's working where, filtered by today/week/month
- Quota Tracking: View quota usage and remaining quota for each engineer
- Statistics: Quick stats on total arrangements, home/office counts
- Real-time Updates: Click refresh to get latest data
Views:ā
-
Arrangements View:
- Grouped by date
- Shows engineer name, location, and timestamp
- Filterable by period (today, week, month)
-
Quotas View:
- Weekly quota status for all engineers
- Color-coded status (over quota, at limit, remaining)
- Breakdown by location type
API Endpointsā
Webhook Endpointā
- POST
/api/slack/events- Receives Slack events (reactions)
Configurationā
- GET
/api/slack/config- Get Slack configuration - POST
/api/slack/config- Set/update Slack configuration
Work Arrangementsā
- GET
/api/work-arrangements- Get arrangements- Query params:
period(today/week/month),engineerId
- Query params:
Quotasā
- GET
/api/work-arrangements/quotas- Get quota information- Query params:
engineerId,week,year
- Query params:
Firestore Collectionsā
The integration uses the following Firestore collections:
-
work-arrangements: Individual arrangement records
- Stores location, date, engineer info, emoji used
-
work-arrangement-quotas: Weekly quota summaries
- Aggregates arrangements by engineer and week
- Tracks quota usage and remaining quota
-
system/slack-config: Slack configuration (singleton)
- Stores tokens, channel ID, emoji mappings, quota settings
Security Considerationsā
- Webhook Verification: All Slack requests are verified using the signing secret
- Token Storage: Store sensitive tokens as environment variables
- Request Timestamps: Requests older than 5 minutes are rejected
- Access Control: Admin dashboard should be protected with authentication
Troubleshootingā
Webhook Not Receiving Eventsā
- Verify the webhook URL is publicly accessible
- Check Slack Event Subscriptions page for errors
- Verify signing secret matches your environment variable
- Check server logs for verification failures
Reactions Not Being Trackedā
- Ensure bot is added to the channel
- Verify emoji mappings match configured emojis
- Check if engineer has slackUserId mapped
- Review server logs for processing errors
Quota Not Updatingā
- Verify week calculation (ISO week vs calendar week)
- Check quota settings (weekStartsOn)
- Review Firestore quotas collection for data
Automated Daily Messages (Optional)ā
You can set up a scheduled function to post daily messages automatically:
Using Cloud Scheduler + Cloud Functions:ā
- Create a Cloud Function that posts the daily message
- Use Cloud Scheduler to trigger it daily at your configured time
- Example function:
import { WebClient } from '@slack/web-api';
export async function postDailyMessage() {
const client = new WebClient(process.env.SLACK_BOT_TOKEN);
await client.chat.postMessage({
channel: process.env.SLACK_CHANNEL_ID,
text: 'Where are you working from today?',
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: '*Good morning team!* š
\n\nWhere are you working from today?\nReact with:\nš - Working from home\nš¢ - Main office\nšļø - Alternate office'
}
}
]
});
}
Supportā
For issues or questions:
- Check server logs for error messages
- Verify all configuration steps are completed
- Test webhook endpoint manually
- Review Slack app configuration in API dashboard