Skip to content

Gmail updates for email replies #16552

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

Merged
merged 9 commits into from
May 6, 2025
Merged

Gmail updates for email replies #16552

merged 9 commits into from
May 6, 2025

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented May 3, 2025

  • For "New Email Recieved" trigger, I added cc and bcc recipients (if available) to to the parsedHeaders field in the event.
  • For "Send Email" action, I added an optional replyAll prop which replaces the to, cc, and bcc fields with the from, to, cc, and bcc recipients (if available) from the original message.

Summary by CodeRabbit

  • New Features

    • Added support for "Reply All" when replying to emails, allowing users to reply to all original recipients (From, To, CC, BCC) in the Send Email action.
    • When "Reply All" is selected, recipient fields (To, CC, BCC) are automatically managed and hidden for convenience.
    • Enhanced email processing to include CC and BCC fields in structured email data.
  • Chores

    • Updated version numbers for multiple Gmail actions and sources to reflect recent changes and improvements.

Copy link

vercel bot commented May 3, 2025

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview May 6, 2025 2:03am
pipedream-docs ⬜️ Ignored (Inspect) May 6, 2025 2:03am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 6, 2025 2:03am

Copy link
Contributor

coderabbitai bot commented May 3, 2025

Walkthrough

This update primarily increments version numbers across multiple Gmail action and source modules, reflecting minor updates or maintenance. Notably, the "Send Email" action and supporting logic in gmail.app.mjs are enhanced to support a "reply all" feature: when replying to an email, users can now choose to reply to all original recipients. The code for parsing and handling "cc" and "bcc" headers is also improved in the email processing logic. No breaking changes or removals are present.

Changes

File(s) Change Summary
components/gmail/actions/add-label-to-email/add-label-to-email.mjs
components/gmail/actions/approve-workflow/approve-workflow.mjs
components/gmail/actions/archive-email/archive-email.mjs
components/gmail/actions/create-draft/create-draft.mjs
components/gmail/actions/download-attachment/download-attachment.mjs
components/gmail/actions/find-email/find-email.mjs
components/gmail/actions/list-labels/list-labels.mjs
components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs
components/gmail/actions/update-org-signature/update-org-signature.mjs
components/gmail/actions/update-primary-signature/update-primary-signature.mjs
components/gmail/sources/new-attachment-received/new-attachment-received.mjs
components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs
components/gmail/sources/new-email-received/new-email-received.mjs
components/gmail/sources/new-labeled-email/new-labeled-email.mjs
components/gmail/sources/new-sent-email/new-sent-email.mjs
Incremented version numbers in metadata for multiple Gmail actions and sources; no code or logic changes.
components/gmail/actions/send-email/send-email.mjs Added support for "reply all" via new replyAll property and logic; updated inReplyTo to trigger UI reloads; summary message now uses a generic success message. Version incremented.
components/gmail/gmail.app.mjs Enhanced getOptionsToSendEmail to handle "reply all" by extracting and combining "From", "To", "Cc", and "Bcc" headers for recipient lists when replying to all, excluding the current user.
components/gmail/sources/common/base.mjs Modified processEmail to extract and parse "cc" and "bcc" headers, adding them to the structured email object.
components/gmail/package.json Incremented package version from 0.3.0 to 0.3.2.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SendEmailAction
    participant GmailApp

    User->>SendEmailAction: Initiate send email (with inReplyTo)
    SendEmailAction->>GmailApp: getOptionsToSendEmail(props)
    alt replyAll is true
        GmailApp->>GmailApp: Extract From, To, Cc, Bcc from original message
        GmailApp->>SendEmailAction: Return all recipients as to/cc/bcc
    else replyAll is false
        GmailApp->>SendEmailAction: Return standard recipients
    end
    SendEmailAction->>User: Email sent summary (generic success message)
Loading

Possibly related PRs

  • PipedreamHQ/pipedream#16276: Introduces the archive-email action, which is related to this PR where only the version for that action is incremented.
  • PipedreamHQ/pipedream#16536: Adds new props and logic to the create-draft action, preceding the version bump in this PR.

Suggested labels

action, User submitted

Suggested reviewers

  • michelle0927

Poem

A rabbit hops through code so bright,
Version bumps left and right!
Now when you reply, reply to all—
No friend or CC left in the hall.
Headers parsed, recipients found,
In Gmail’s warren, updates abound!
🐇✉️

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/gmail/actions/send-email/send-email.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b516059 and 461b753.

📒 Files selected for processing (1)
  • components/gmail/actions/send-email/send-email.mjs (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/gmail/actions/send-email/send-email.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@michelle0927 michelle0927 marked this pull request as ready for review May 3, 2025 18:35
Copy link
Contributor

@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

🧹 Nitpick comments (1)
components/gmail/gmail.app.mjs (1)

306-322: Consider removing the current user from recipients list

The current implementation adds all recipients to the reply, but doesn't filter out the current user's email address. This could result in the user receiving their own email.

if (props.replyAll) {
  const from = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "from");
  const to = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "to");
  const cc = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "cc");
  const bcc = repliedMessage.payload.headers.find(({ name }) => name.toLowerCase() === "bcc");
  opts.to = from.value.split(",");
  opts.to.push(...to.value.split(","));
+  // Filter out the current user's email address
+  const currentUserEmail = email.toLowerCase().trim();
+  opts.to = opts.to.filter(addr => {
+    // Extract email from possible format like "Name <[email protected]>"
+    const match = addr.match(/<(.+?)>/) || [null, addr.trim()];
+    return match[1].toLowerCase() !== currentUserEmail;
+  });
  opts.to = [
    ...new Set(opts.to),
  ];
  if (cc) {
    opts.cc = cc.value;
  }
  if (bcc) {
    opts.bcc = bcc.value;
  }
}

This ensures the sender doesn't receive their own email when using the "reply all" feature.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f57408 and 3b11f03.

📒 Files selected for processing (19)
  • components/gmail/actions/add-label-to-email/add-label-to-email.mjs (1 hunks)
  • components/gmail/actions/approve-workflow/approve-workflow.mjs (1 hunks)
  • components/gmail/actions/archive-email/archive-email.mjs (1 hunks)
  • components/gmail/actions/create-draft/create-draft.mjs (1 hunks)
  • components/gmail/actions/download-attachment/download-attachment.mjs (1 hunks)
  • components/gmail/actions/find-email/find-email.mjs (1 hunks)
  • components/gmail/actions/list-labels/list-labels.mjs (1 hunks)
  • components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs (1 hunks)
  • components/gmail/actions/send-email/send-email.mjs (4 hunks)
  • components/gmail/actions/update-org-signature/update-org-signature.mjs (1 hunks)
  • components/gmail/actions/update-primary-signature/update-primary-signature.mjs (1 hunks)
  • components/gmail/gmail.app.mjs (1 hunks)
  • components/gmail/package.json (1 hunks)
  • components/gmail/sources/common/base.mjs (1 hunks)
  • components/gmail/sources/new-attachment-received/new-attachment-received.mjs (1 hunks)
  • components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs (1 hunks)
  • components/gmail/sources/new-email-received/new-email-received.mjs (1 hunks)
  • components/gmail/sources/new-labeled-email/new-labeled-email.mjs (1 hunks)
  • components/gmail/sources/new-sent-email/new-sent-email.mjs (1 hunks)
🔇 Additional comments (21)
components/gmail/actions/list-labels/list-labels.mjs (1)

7-7: Bump action version
Version updated to "0.0.3" to align with the coordinated version increments across Gmail actions and sources in this PR. No functional changes.

components/gmail/actions/download-attachment/download-attachment.mjs (1)

10-10: Version Bump Consistency
The version number has been correctly incremented from 0.0.5 to 0.0.6 to reflect this non-functional update. This matches the version bumps applied across the other Gmail action components in this PR.

components/gmail/actions/update-primary-signature/update-primary-signature.mjs (1)

7-7: Consistent version bump to 0.0.6
The version has been incremented from 0.0.5 to 0.0.6 to align with the coordinated updates across Gmail action modules. No functional changes detected.

components/gmail/actions/create-draft/create-draft.mjs (1)

9-9: Approve version bump
The action’s version has been updated from 0.0.5 to 0.0.6, aligning with the coordinated version increments across other Gmail action modules in this PR.

components/gmail/sources/new-attachment-received/new-attachment-received.mjs (1)

9-9: Version bump is consistent
The version string has been updated from "0.0.10" to "0.0.11" to align with coordinated releases across Gmail components in this PR. No functional changes were introduced.

components/gmail/sources/new-email-matching-search/new-email-matching-search.mjs (1)

9-9: Version bump is appropriate
The source’s version has been correctly updated from 0.0.8 to 0.0.9, keeping it in sync with the other Gmail components in this release. No other changes are present in this file.

components/gmail/actions/update-org-signature/update-org-signature.mjs (1)

11-11: Version bump is consistent
The version has been updated from "0.0.5" to "0.0.6", matching the coordinated increments across other Gmail action components in this PR.

components/gmail/actions/find-email/find-email.mjs (1)

7-7: Version bump for Find Email action.
The component version has been updated from "0.0.10" to "0.0.11" to reflect this release’s coordinated updates.

components/gmail/actions/archive-email/archive-email.mjs (1)

8-8: Version bump for Archive Email action.
The component version has been updated from "0.0.1" to "0.0.2" in line with the overall Gmail actions package update.

components/gmail/actions/add-label-to-email/add-label-to-email.mjs (1)

7-7: Version bump for Add Label to Email action.
The component version has been updated from "0.0.7" to "0.0.8" to align with the other Gmail action updates.

components/gmail/sources/new-email-received/new-email-received.mjs (1)

18-18: Version bump for New Email Received source.
The source version has been updated from "0.2.3" to "0.2.4" to coincide with related Gmail component enhancements in this release.

components/gmail/actions/remove-label-from-email/remove-label-from-email.mjs (1)

7-7: Version bump for Remove Label from Email action.
The component version has been updated from "0.0.4" to "0.0.5" as part of the coordinated Gmail actions package version increment.

components/gmail/package.json (1)

3-3: Version bump reflects new features and improvements.

This version increment from 0.3.0 to 0.3.1 properly reflects the minor enhancements made across Gmail components, particularly the addition of cc/bcc header parsing and reply-all functionality.

components/gmail/actions/approve-workflow/approve-workflow.mjs (1)

7-7: Version increment is appropriate.

The version bump from 0.0.3 to 0.0.4 aligns with the coordinated updates across Gmail components, maintaining version consistency across the package.

components/gmail/sources/new-labeled-email/new-labeled-email.mjs (1)

11-11: Version increment is appropriate.

The version bump from 0.0.10 to 0.0.11 maintains consistency with other Gmail component updates in this PR.

components/gmail/sources/new-sent-email/new-sent-email.mjs (1)

9-9: Version increment is appropriate.

The version bump from 0.0.9 to 0.0.10 aligns with other Gmail component updates in this PR, maintaining version consistency.

components/gmail/sources/common/base.mjs (1)

78-79: Enhancement for cc/bcc recipients handling.

Good addition of cc and bcc email header parsing to complete the recipient information in the processed email object. This change properly implements the PR objective of adding cc/bcc recipients to the parsedHeaders field.

The implementation correctly uses the existing parseEmail method pattern and maintains consistency with how other email headers are processed.

components/gmail/actions/send-email/send-email.mjs (4)

9-9: LGTM - Version increment

Appropriately incremented version number for tracking changes.


87-87: LGTM - Props reload configuration

Adding reloadProps: true to the inReplyTo property is appropriate to ensure UI updates when this value changes.


96-111: LGTM - Well-structured dynamic properties handling

The additionalProps method implementation is well-structured:

  1. It adds the replyAll property only when needed (when inReplyTo is set)
  2. It properly hides the redundant fields when reply all is enabled
  3. It ensures the UI is updated when replyAll value changes via reloadProps: true

120-120: LGTM - Improved export summary

Good update to use opts.to instead of this.to in the summary message, ensuring the proper recipients are displayed when using "reply all" functionality.

@jlil
Copy link

jlil commented May 4, 2025

@michelle0927 this is great start, thank you so much!
Since the replyAll now includes the original to value, we should try to remove the user's calendar email from the list that matches the address in /gmail/v1/users/me/profile. Thoughts?

}
if (bcc) {
opts.bcc = bcc.value;
}
Copy link

Choose a reason for hiding this comment

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

It'd be nice to set the inReplyTo and reference props to messageId automatically here

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that'd be nice but Wwe don't want to set props references automatically from the component code because step references can change and it also doesn't work in the context of Pipedream Connect

@dannyroosevelt
Copy link
Collaborator

@michelle0927 this is great start, thank you so much!

Since the replyAll now includes the original to value, we should try to remove the user's calendar email from the list that matches the address in /gmail/v1/users/me/profile. Thoughts?

I don't totally understand the ask, can you clarify?

@jlil
Copy link

jlil commented May 4, 2025

@dannyroosevelt since the to field we're setting uses the original to header value, this will also include the email of the user replying.

Headers:

ReplyAll should set this:

not this:

@michelle0927 michelle0927 moved this from Doing to Ready for PR Review in Component (Source and Action) Backlog May 5, 2025
jcortes
jcortes previously approved these changes May 5, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927 lgtm! Ready for QA!

@jcortes jcortes moved this from Ready for PR Review to Ready for QA in Component (Source and Action) Backlog May 5, 2025
@vunguyenhung vunguyenhung moved this from Ready for QA to In QA in Component (Source and Action) Backlog May 6, 2025
@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test report
https://vunguyenhung.notion.site/Gmail-updates-for-email-replies-1eabf548bb5e81bcad48cf79612b48e2

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit 1c2cc67 into master May 6, 2025
11 checks passed
@michelle0927 michelle0927 deleted the gmail-updates branch May 6, 2025 15:03
@github-project-automation github-project-automation bot moved this from Ready for Release to Done in Component (Source and Action) Backlog May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants