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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-add-label-to-email",
name: "Add Label to Email",
description: "Add label(s) to an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
version: "0.0.7",
version: "0.0.8",
type: "action",
props: {
gmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-approve-workflow",
name: "Approve Workflow",
description: "Suspend the workflow until approved by email. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
gmail,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/actions/archive-email/archive-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gmail-archive-email",
name: "Archive Email",
description: "Archive an email message. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
gmail,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/actions/create-draft/create-draft.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-create-draft",
name: "Create Draft",
description: "Create a draft from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.drafts/create)",
version: "0.1.0",
version: "0.1.1",
type: "action",
props: {
gmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "gmail-download-attachment",
name: "Download Attachment",
description: "Download an attachment by attachmentId to the /tmp directory. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages.attachments/get)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
gmail,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/actions/find-email/find-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-find-email",
name: "Find Email",
description: "Find an email using Google's Search Engine. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/list)",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
gmail,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/actions/list-labels/list-labels.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-list-labels",
name: "List Labels",
description: "List all the existing labels in the connected account. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.labels/list)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
gmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-remove-label-from-email",
name: "Remove Label from Email",
description: "Remove label(s) from an email message. [See the docs](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/modify)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
gmail,
Expand Down
21 changes: 19 additions & 2 deletions components/gmail/actions/send-email/send-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-send-email",
name: "Send Email",
description: "Send an email from your Google Workspace email account. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.messages/send)",
version: "0.1.8",
version: "0.1.9",
type: "action",
props: {
gmail,
Expand Down Expand Up @@ -84,6 +84,7 @@ export default {
label: "In Reply To",
description: "Specify the `message-id` this email is replying to.",
optional: true,
reloadProps: true,
},
mimeType: {
propDefinition: [
Expand All @@ -92,6 +93,22 @@ export default {
],
},
},
additionalProps(existingProps) {
const props = {};
if (this.inReplyTo) {
props.replyAll = {
type: "boolean",
label: "Reply All",
description: "Set to `true` to send reply to emails in the \"From\", \"To\", \"CC\", and \"BCC\" (if available) of the original email",
optional: true,
reloadProps: true,
};
}
existingProps.to.hidden = !!this.replyAll;
existingProps.cc.hidden = !!this.replyAll;
existingProps.bcc.hidden = !!this.replyAll;
return props;
},
async run({ $ }) {
this.attachmentFilenames = utils.parseArray(this.attachmentFilenames);
this.attachmentUrlsOrPaths = utils.parseArray(this.attachmentUrlsOrPaths);
Expand All @@ -100,7 +117,7 @@ export default {
}
const opts = await this.gmail.getOptionsToSendEmail($, this);
const response = await this.gmail.sendEmail(opts);
$.export("$summary", `Successfully sent email to ${this.to}`);
$.export("$summary", "Successfully sent the email");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "Update Signature for Email in Organization",
description: `Update the signature for a specific email address in an organization.
A Google Cloud service account with delegated domain-wide authority is required for this action. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/update)`,
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
gmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gmail-update-primary-signature",
name: "Update Signature for Primary Email Address",
description: "Update the signature for the primary email address. [See the documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.settings.sendAs/update)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
gmail,
Expand Down
29 changes: 29 additions & 0 deletions components/gmail/gmail.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,35 @@ export default {
opts.inReplyTo = inReplyTo;
opts.references = inReplyTo;
opts.threadId = repliedMessage.threadId;
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;
}
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

}
} catch (err) {
opts.threadId = props.inReplyTo;
}
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gmail",
"version": "0.3.1",
"version": "0.3.2",
"description": "Pipedream Gmail Components",
"main": "gmail.app.mjs",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions components/gmail/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export default {
"subject": this.getHeaderValue(headers, "subject"),
"from": this.parseEmail(this.getHeaderValue(headers, "from")),
"to": this.parseEmail(this.getHeaderValue(headers, "to")),
"cc": this.parseEmail(this.getHeaderValue(headers, "cc")),
"bcc": this.parseEmail(this.getHeaderValue(headers, "bcc")),
"reply-to": this.parseEmail(this.getHeaderValue(headers, "reply-to")),
"date": this.getHeaderValue(headers, "date"),
"snippet": msg.snippet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-attachment-received",
name: "New Attachment Received",
description: "Emit new event for each attachment in a message received. This source is capped at 100 max new messages per run.",
version: "0.0.10",
version: "0.0.11",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-email-matching-search",
name: "New Email Matching Search",
description: "Emit new event when an email matching the search criteria is received. This source is capped at 100 max new messages per run.",
version: "0.0.8",
version: "0.0.9",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
name: "New Email Received",
description: "Emit new event when a new email is received.",
type: "source",
version: "0.2.3",
version: "0.2.4",
dedupe: "unique",
props: {
gmail,
Expand All @@ -41,14 +41,14 @@
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
},
},
serviceAccountKeyJson: {

Check warning on line 44 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJson must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "string",
label: "Service Account Key JSON",
optional: true,
hidden: true,
reloadProps: true,
},
serviceAccountKeyJsonInstructions: {

Check warning on line 51 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJsonInstructions must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 51 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop serviceAccountKeyJsonInstructions must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `1) [Create a service account in GCP](https://cloud.google.com/iam/docs/creating-managing-service-accounts) and set the following permission: **Pub/Sub Admin**
Expand Down Expand Up @@ -104,7 +104,7 @@
description: "Emails with the specified labels will be excluded from results",
optional: true,
},
permissionAlert: {

Check warning on line 107 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop permissionAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 107 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop permissionAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "error",
content: `Unable to grant publish permission to Gmail API service account.
Expand All @@ -117,7 +117,7 @@
`,
hidden: true,
},
latencyWarningAlert: {

Check warning on line 120 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop latencyWarningAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 120 in components/gmail/sources/new-email-received/new-email-received.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop latencyWarningAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "warning",
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
name: "New Labeled Email",
description: "Emit new event when a new email is labeled.",
type: "source",
version: "0.0.10",
version: "0.0.11",
dedupe: "unique",
props: {
gmail,
Expand Down
2 changes: 1 addition & 1 deletion components/gmail/sources/new-sent-email/new-sent-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "gmail-new-sent-email",
name: "New Sent Email",
description: "Emit new event for each new email sent. (Maximum of 100 events emited per execution)",
version: "0.0.9",
version: "0.0.10",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/oto/oto.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
2 changes: 1 addition & 1 deletion components/transloadit/transloadit.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
12 changes: 4 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading