afterhours-shift-manager/src/handler.py
Adam Moussa 4d0cdb5cfb Initial commit: after-hours shift manager Slack bot
Slack Bolt app on Lambda for managing on-call shifts. Employees can
pick up, drop, and swap shifts via /oncall commands. Changes update
3CX ring group 800 routing in real time for same-day shifts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 18:32:32 -04:00

38 lines
1.1 KiB
Python

"""Lambda handler — Slack Bolt app entry point."""
import logging
import os
import boto3
from slack_bolt.adapter.aws_lambda import SlackRequestHandler
from src.app import create_app
logger = logging.getLogger()
logger.setLevel(logging.INFO)
SlackRequestHandler.clear_all_log_handlers()
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s: %(message)s", level=logging.INFO)
# Lazy-initialized app singleton
_slack_handler = None
def _get_handler() -> SlackRequestHandler:
global _slack_handler
if _slack_handler is None:
ssm = boto3.client("ssm")
bot_token = ssm.get_parameter(
Name=os.environ["SLACK_BOT_TOKEN_PARAM"], WithDecryption=True
)["Parameter"]["Value"]
signing_secret = ssm.get_parameter(
Name=os.environ["SLACK_SIGNING_SECRET_PARAM"], WithDecryption=True
)["Parameter"]["Value"]
app = create_app(bot_token, signing_secret)
_slack_handler = SlackRequestHandler(app=app)
return _slack_handler
def handler(event, context):
return _get_handler().handle(event, context)