Slack bot for managing after-hours on-call shifts with 3CX integration
Find a file
Adam Moussa 9deb8bf251 Email weekly pay summary to payroll via SES on Mondays
Sends an HTML pay summary email to configured payroll recipients
alongside the existing Slack post. Uses SES with noreply@seahaven.com
as sender. Recipients configured via PAYROLL_RECIPIENTS env var
(set to adam@seahaven.com for testing, switch to payroll@seahaven.com
for production).

Closes #3
2026-04-07 18:54:19 -04:00
scripts Initial commit: after-hours shift manager Slack bot 2026-04-03 18:32:32 -04:00
src Email weekly pay summary to payroll via SES on Mondays 2026-04-07 18:54:19 -04:00
.gitignore Initial commit: after-hours shift manager Slack bot 2026-04-03 18:32:32 -04:00
README.md Initial commit: after-hours shift manager Slack bot 2026-04-03 18:32:32 -04:00
requirements.txt Add 3CX roster sync Lambda with daily EventBridge trigger 2026-04-07 18:43:19 -04:00
SETUP.md Initial commit: after-hours shift manager Slack bot 2026-04-03 18:32:32 -04:00
template.yaml Email weekly pay summary to payroll via SES on Mondays 2026-04-07 18:54:19 -04:00

After-Hours Shift Manager

Slack bot for managing after-hours on-call shifts at Sea Haven Industries. Employees can pick up, drop, and swap shifts directly from Slack. Changes automatically update 3CX ring group 800 routing.

How It Works

A recurring weekly schedule assigns employees to after-hours phone duty (5pm-8am). Any unassigned day shows as Available in Slack with a pickup button. When someone picks up or drops a shift for today, the 3CX phone system is updated immediately. Future changes take effect when the 3CX scheduler runs at 8am.

Slack Commands

Command Description
/oncall Show this week's schedule
/oncall next Show next week's schedule
/oncall pick <date> Pick up an available shift
/oncall drop <date> Drop your shift (marks it available)
/oncall swap <date> @person Hand your shift to someone else
/oncall register <ext> Link your Slack account to your phone extension
/oncall roster Show all employees and their link status
/oncall help Show help

Dates accept: today, tomorrow, monday-sunday, 4/5, 2026-04-05

Architecture

  • Runtime: Python 3.12 on AWS Lambda (via API Gateway)
  • Data: DynamoDB single-table (afterhours-shifts)
  • IaC: AWS SAM (template.yaml)
  • Slack: Slack Bolt framework with /oncall slash command
  • 3CX Integration: Invokes the 3cx-ring-group-scheduler Lambda for same-day changes; the scheduler reads DynamoDB for future dates

DynamoDB Schema

Single table with PK / SK keys:

PK SK Description
ROSTER <extension> Employee: name, extension, slack_user_id
WEEKLY <DayName> Default weekly schedule: extension, name
OVERRIDE <YYYY-MM-DD> Date override from pickup/drop (or OPEN)
CONFIG CONFIG Settings: ring_group, fallback_extension

Deployment

See SETUP.md for full deployment and Slack app creation instructions.

Quick reference:

# Build and deploy
sam build
sam deploy --guided --stack-name afterhours-shift-manager --region us-east-1

# Seed initial schedule data
python scripts/seed_schedule.py

SSM Parameters

Parameter Description
/afterhours-shift-manager/slack-bot-token Slack bot OAuth token (xoxb-...)
/afterhours-shift-manager/slack-signing-secret Slack app signing secret
/afterhours-shift-manager/channel-id Slack channel ID for notifications

Weekly Auto-Post

Every Monday at 7am ET, the bot posts the week's schedule to the configured channel with pickup buttons for any available shifts.