Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify workflow failure with Email when the workflow is triggered by webhooks #333

Merged
merged 18 commits into from
Jan 28, 2025

Conversation

satococoa
Copy link
Contributor

@satococoa satococoa commented Jan 27, 2025

Summary

This Pull Request introduces the following improvements and features:

  1. Email notification on workflow errors triggered via GitHub Webhook.
  2. Session-independent usage reporting for agents.
  3. GitHub comment posting only when the flow execution is successfully completed.

Changes

  • Added nodemailer and its type definitions
    • Implemented the sendEmail function using nodemailer, providing configurable SMTP settings through environment variables.
  • Introduced a debug mode (SEND_EMAIL_DEBUG)
    • Allows logging email content to the console instead of sending it for local or development usage.
  • Implemented an onStepFail callback
    • Ensures team members are notified via email if a workflow execution triggered by GitHub Webhook fails.
  • Modified reportAgentTimeUsage
    • Removed session-based dependencies by accepting agentId explicitly and querying the appropriate team and subscription details.
  • Conditionally post comments to GitHub
    • Only post issue comments upon successful workflow completion, preventing redundant or partial information from appearing.

Why nodemailer?

nodemailer vs. emailjs

  • Ecosystem and Community: nodemailer has a larger user base and more extensive documentation, making it easier to find solutions and best practices.
  • Active Maintenance: nodemailer is regularly updated and well-maintained.

https://npmtrends.com/emailjs-vs-nodemailer

nodemailer vs. aws-sdk/client-ses

  • Vendor Neutrality: nodemailer can send emails via any SMTP server. This provides flexibility if you decide to switch providers or are not exclusively using AWS.

TODO

  • Add SMTP_XXXX environment values to Preview
  • Add SMTP_XXXX environment values to Production

@satococoa satococoa self-assigned this Jan 27, 2025
Copy link

vercel bot commented Jan 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
giselle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 27, 2025 7:31am

Copy link
Member

@shige shige left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

bun.lockb Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: @satococoa

I would appreciate it if you could delete this file!
ref: #306

@satococoa satococoa merged commit 87ff659 into main Jan 28, 2025
9 checks passed
@satococoa satococoa deleted the notify-workflow-failure-triggered-by-webhook branch January 28, 2025 02:23
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.

3 participants