App recipes
Save Gmail attachments to Google Drive automatically with Duaer
In Duaer, each new email with attachments uploads every file under its original name to a Google Drive folder.
Build the attachment archive in Duaer
- Add Gmail Trigger, turn off Simplify, turn on Download Attachments under Options, and set Search under Filters to has:attachment.
- Attachments land on attachment_0, attachment_1, and so on. Add Code with the code below for one item per file, each on data.
- To keep only PDFs, add If with {{ $json.fileName.toLowerCase().endsWith('.pdf') }} is true.
- Add Google Drive with Resource File and Operation Upload; Input Data Field Name data, File Name {{ $json.fileName }}, then pick Parent Drive and Parent Folder.
- Publish the digital organization.
const out = [];
for (const item of $input.all()) {
for (const key of Object.keys(item.binary ?? {})) {
out.push({
json: { ...item.json, fileName: item.binary[key].fileName },
binary: { data: item.binary[key] },
});
}
}
return out;Folders by sender or month
Prefix File Name with a date, such as {{ $now.toFormat('yyyy-MM') }}-{{ $json.fileName }}. For real folders, create them with the Google Drive Folder create operation first, then set Parent Folder by expression.
Questions
Does Duaer save the same attachments twice?
No. The Duaer Gmail Trigger fires once per new email; only a manual rerun uploads again.
Can Duaer save attachments from a non-Gmail mailbox?
Yes. Swap Gmail Trigger for Email Trigger (IMAP) with attachment download on; the rest of the Duaer flow stays the same.
In this section
Upload a file with Google Drive in Duaer
In Duaer, Google Drive defaults to Authentication OAuth2, Resource File, and Operation Upload. Input Data Field Name defaults to data. You need a googleDriveOAuth2Api credential.
NodesSend mail with Gmail in Duaer
In Duaer, Gmail defaults to Authentication OAuth2, Resource Message, and Operation Send. Email Type defaults to HTML. You need a gmailOAuth2 credential.
DataWork with files and images in Duaer
Understand and use binary data in Duaer.
ErrorsFix Google invalid_grant and 7-day token expiry in Duaer
When a Gmail, Google Sheets, or Google Drive credential in Duaer fails with invalid_grant after a few days, the Google app is usually still in Testing. Publish it and reconnect.