Skip to content

Comments

API - Email - include footer note#83

Merged
sweetmantech merged 1 commit intomainfrom
sweetmantech/myc-3788-api-email-include-footer-note
Dec 23, 2025
Merged

API - Email - include footer note#83
sweetmantech merged 1 commit intomainfrom
sweetmantech/myc-3788-api-email-include-footer-note

Conversation

@sweetmantech
Copy link
Contributor

@sweetmantech sweetmantech commented Dec 23, 2025

Summary by CodeRabbit

  • New Features

    • Email responses now generated with both plain text and HTML formatting, including reply instructions and chat links.
  • Refactor

    • Consolidated email response generation to a dedicated module, improving consistency and streamlining the overall process.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Contributor

vercel bot commented Dec 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
recoup-api Ready Ready Preview Dec 23, 2025 1:14pm

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

Introduces a new generateEmailResponse module that encapsulates email response generation with validation, agent-based message generation, and HTML footer appending. Updates respondToInboundEmail to use this dedicated function instead of inline agent-based logic, eliminating direct dependencies on getGeneralAgent and getEmailRoomMessages.

Changes

Cohort / File(s) Summary
New email response generation module
lib/emails/inbound/generateEmailResponse.ts
New async function that validates roomId presence, retrieves a general agent, fetches email room messages, generates text via agent, builds a standardized HTML footer with reply instructions, and returns both text and HTML outputs.
Updated inbound email handler
lib/emails/inbound/respondToInboundEmail.ts
Refactored to use generateEmailResponse instead of inline agent-based logic. Removed direct calls to getGeneralAgent and getEmailRoomMessages. Updated payload construction to use HTML from generateEmailResponse and adjusted memory-saving logic to use the returned text value.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'API - Email - include footer note' is directly related to the main change: adding HTML footer generation to email responses.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sweetmantech/myc-3788-api-email-include-footer-note

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 741d3c0 and dc94eca.

📒 Files selected for processing (2)
  • lib/emails/inbound/generateEmailResponse.ts
  • lib/emails/inbound/respondToInboundEmail.ts
🧰 Additional context used
🧬 Code graph analysis (2)
lib/emails/inbound/generateEmailResponse.ts (3)
lib/chat/validateChatRequest.ts (1)
  • ChatRequestBody (35-37)
lib/agents/generalAgent/getGeneralAgent.ts (1)
  • getGeneralAgent (20-65)
lib/emails/inbound/getEmailRoomMessages.ts (1)
  • getEmailRoomMessages (10-25)
lib/emails/inbound/respondToInboundEmail.ts (2)
lib/emails/inbound/generateEmailResponse.ts (1)
  • generateEmailResponse (14-46)
lib/messages/getMessages.ts (1)
  • getMessages (12-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Vercel Agent Review
🔇 Additional comments (7)
lib/emails/inbound/generateEmailResponse.ts (4)

1-3: LGTM!

Imports are clean and all dependencies are properly referenced.


14-20: LGTM!

Function signature is clear and roomId validation prevents undefined behavior. The error will propagate to the caller (respondToInboundEmail) which has appropriate try-catch handling.


22-28: LGTM!

Agent initialization and message generation logic is correct and follows established patterns.


30-41: HTML escaping for roomId is not necessary—it's always a UUID.

The roomId is either from generateUUID() or retrieved from the database (where it was originally stored as a UUID), making injection impossible. No escaping is required.

lib/emails/inbound/respondToInboundEmail.ts (3)

9-9: LGTM!

Import is correct and properly references the new email response generation module.


38-48: LGTM!

The refactoring correctly uses generateEmailResponse to obtain the HTML with footer, and the payload is properly constructed with the enriched HTML content.


53-58: LGTM!

Correctly saves the plain text (without HTML footer) to memory, ensuring conversation history remains clean while emails include the footer.

@sweetmantech sweetmantech merged commit c286666 into main Dec 23, 2025
3 checks passed
This was referenced Jan 5, 2026
Merged
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