Slack bot for managing after-hours on-call shifts with 3CX integration
Find a file
2026-05-01 16:32:50 -04:00
.github/workflows Default to patch version bumps, add minor bump option (#30) 2026-05-01 15:06:04 -04:00
scripts Initial commit: after-hours shift manager Slack bot 2026-04-03 18:32:32 -04:00
src Fix shift pickup showing error despite succeeding (#31) (#32) 2026-05-01 15:16:11 -04:00
.gitignore Add CodePipeline CI/CD, remove Git sync config (#36) (#36) 2026-05-01 16:18:56 -04:00
buildspec.yml Add CodePipeline CI/CD, remove Git sync config (#36) (#36) 2026-05-01 16:18:56 -04:00
pipeline.yaml Fix CodeBuild environment type for ARM image (#37) 2026-05-01 16:28:13 -04:00
README.md Update README with CI/CD pipeline, pay commands, and Lambda inventory (#38) 2026-05-01 16:32:50 -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 Post shift change notifications to the schedule channel (#21) (#22) 2026-05-01 14:15:56 -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 pay Show last week's bonus pay summary
/oncall rate Show current shift pay rates
/oncall rate default <amount> Set the default per-shift rate
/oncall rate <ext> <amount> Set a per-person shift rate
/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)
PAY <YYYY-MM-DD> Weekly pay record (Monday date key)
CONFIG CONFIG Settings: shift_rate, fallback_extension

Deployment

Merges to main are automatically deployed via CodePipeline + CodeBuild. The pipeline stack (afterhours-shift-manager-pipeline) watches the GitHub repo and runs sam build && sam package then deploys via CloudFormation changeset.

For manual deploys:

sam build
sam deploy

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

Version Bumps

A GitHub Actions workflow runs daily at 6pm ET, collects all PRs merged since the last version tag, creates a semver patch bump (e.g. v1.6.0 → v1.6.1), updates the Slack changelog canvas, and posts a summary to the team channel. Minor bumps can be triggered manually via workflow_dispatch.

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.

Pay Report Email

A weekly Bonus Pay Summary email is sent via SES to payroll@seahaven.com with a table showing each employee's name, rate, and total pay for the week.

Lambda Functions

Function Trigger Purpose
afterhours-shift-manager API Gateway (POST /slack/events) Slack bot — handles /oncall commands and interactive buttons
afterhours-weekly-post EventBridge (Monday 7am ET) Posts weekly schedule to Slack, sends pay report email
afterhours-roster-sync EventBridge (daily 6am ET) Syncs employee roster from 3CX