n8n-nodes-imap-ai
Version:
Simplified IMAP node for n8n with AI-agent support. Clean and modular email and mailbox management for automation workflows.
46 lines • 2.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.renameMailboxOperation = void 0;
const SearchFieldParameters_1 = require("../../../utils/SearchFieldParameters");
exports.renameMailboxOperation = {
operation: {
name: 'Rename',
value: 'renameMailbox',
description: 'Rename mailbox folders for better organization and naming conventions. Perfect for AI agents to standardize folder names, apply naming patterns, or reorganize folder structures.',
},
parameters: [
{
displayName: 'New Mailbox Name',
name: 'newMailboxName',
type: 'string',
default: "={{ $fromAI('new_folder_name', 'New name for the mailbox/folder') }}",
description: 'New name of the mailbox. AI can generate standardized names based on content, patterns, or organizational rules.',
placeholder: 'Invoices-2024 | Support-High-Priority | Project-Alpha-Archive',
required: true,
},
{
...SearchFieldParameters_1.parameterSelectMailbox,
description: 'Select the mailbox to rename. AI agents can specify existing folders to standardize or reorganize.',
},
],
async executeImapAction(context, itemIndex, client) {
var _a, _b;
const returnData = [];
const mailboxPath = (0, SearchFieldParameters_1.getMailboxPathFromNodeParameter)(context, itemIndex);
const newMailboxName = context.getNodeParameter('newMailboxName', itemIndex);
(_a = context.logger) === null || _a === void 0 ? void 0 : _a.info(`Renaming mailbox "${mailboxPath}" to "${newMailboxName}"`);
const imapResp = await client.mailboxRename(mailboxPath, newMailboxName);
(_b = context.logger) === null || _b === void 0 ? void 0 : _b.info(JSON.stringify(imapResp));
const item_json = JSON.parse(JSON.stringify(imapResp));
item_json.operation = 'renameMailbox';
item_json.oldName = mailboxPath;
item_json.newName = newMailboxName;
item_json.success = true;
item_json.renamedAt = new Date().toISOString();
returnData.push({
json: item_json,
});
return returnData;
},
};
//# sourceMappingURL=MailboxRename.js.map