Skip to content

Add email notification support for workflow events - #114

Closed
kael-developer[bot] wants to merge 1 commit into
ai-devfrom
agent/add-email-notification-support-for-workf
Closed

Add email notification support for workflow events#114
kael-developer[bot] wants to merge 1 commit into
ai-devfrom
agent/add-email-notification-support-for-workf

Conversation

@kael-developer

Copy link
Copy Markdown
Contributor

Why

Problem
Only Slack/Webhook notifications exist; organizations that rely on email alerts cannot be notified when a workflow succeeds, fails, or is retried.

Solution
Introduce configurable email notifications using a background worker (Celery) that sends templated messages via SMTP when specific workflow events occur.

Value
Operators receive direct email alerts, increasing visibility of critical failures and enabling quicker response times for teams without Slack.

What changed

Files created:

  • requirements.txt — added celery and aiosmtplib dependencies.
  • src/app/notifications/email.py — async send_email(to: str, subject: str, body: str) using aiosmtplib.
  • src/app/notifications/tasks.py — Celery app and notify_workflow_event(event_type: str, workflow_id: str, recipient: str) task that renders Jinja2 templates and calls send_email.
  • src/app/notifications/templates/workflow_success.txt — Jinja2 template for success notifications.
  • src/app/notifications/templates/workflow_failure.txt — Jinja2 template for failure notifications.
  • src/app/notifications/templates/workflow_retry.txt — Jinja2 template for retry notifications.
  • src/app/cli/notifications.py — CLI command sdlc notify-test --email you@example.com that sends a test email via send_email.
  • tests/integration/test_email_notifications.py — integration test that patches send_email and asserts correct call on a simulated failure event.

Files modified:

  • src/app/config.py — added SMTP configuration variables (SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, DEFAULT_EMAIL_RECIPIENTS) with environment variable loading.
  • src/app/events.py — extended event dispatcher to enqueue notify_workflow_event Celery task for workflow_success, workflow_failure, and workflow_retry events, using recipients from config.
  • sdlc/main.py — registered the new notifications CLI group.
  • docker-compose.yml — added worker service that runs the Celery worker using the same image.
  • .github/workflows/ci.yml — added steps to start a mock SMTP container (MailHog) for integration tests.

Logic implemented:

  • Async email sending via SMTP with configurable credentials.
  • Celery task creation and registration for workflow event notifications.
  • Jinja2 templating system for subject/body generation.
  • Event dispatcher integration to trigger email notifications.
  • CLI command for manual email connectivity testing.
  • Integration test ensuring email function is invoked with correct parameters without sending real mail.
  • Docker Compose worker service for background task processing.
  • CI pipeline enhancement to provide a mock SMTP service for testing.

Build verified:

  • pytest -q tests/integration/test_email_notifications.py → exit code 0, test passed.

Acceptance criteria

  1. Configuration options for SMTP are present in the config schema and can be set via environment variables. 2. When a workflow fails, a Celery task is enqueued and send_email is invoked with a subject containing the workflow ID and status. 3. The CLI sdlc notify-test sends a test email to the supplied address and prints success/failure. 4. Integration test validates that the email function is called with correct parameters without sending real mail. 5. No existing Slack/webhook functionality is broken (all previous tests still pass).

Closes #111

🤖 Implemented automatically by Kael AI Agent

@unitz007
unitz007 deleted the branch ai-dev March 15, 2026 20:00
@unitz007 unitz007 closed this Mar 15, 2026
@unitz007
unitz007 deleted the agent/add-email-notification-support-for-workf branch March 15, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant