n8n-nodes-imap-ai
Version:
Simplified IMAP node for n8n with AI-agent support. Clean and modular email and mailbox management for automation workflows.
67 lines • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createMailboxOperation = void 0;
const SearchFieldParameters_1 = require("../../../utils/SearchFieldParameters");
exports.createMailboxOperation = {
operation: {
name: 'Create',
value: 'createMailbox',
description: 'Create new mailbox folders for email organization. Perfect for AI agents to automatically create folders based on senders, subjects, or categories for intelligent email sorting.',
},
parameters: [
{
displayName: 'Top Level Mailbox',
name: 'topLevelMailbox',
type: 'boolean',
default: false,
description: 'Whether the mailbox is a top level mailbox or a child mailbox. AI can decide based on organizational structure.',
required: true,
},
{
...SearchFieldParameters_1.parameterSelectMailbox,
description: 'Parent mailbox where the new mailbox will be created. AI agents can specify existing folders like: INBOX, Archive, Projects, etc.',
required: false,
displayOptions: {
show: {
topLevelMailbox: [false],
},
},
},
{
displayName: 'Mailbox Name',
name: 'mailboxName',
type: 'string',
default: "={{ $fromAI('folder_name', 'Name of the new mailbox/folder to create') }}",
description: 'Name of the mailbox to create. AI can generate names based on email content, senders, or categories.',
placeholder: 'Invoices | Support-Tickets | Project-Alpha | Client-Reports',
required: true,
},
],
async executeImapAction(context, itemIndex, client) {
var _a;
const returnData = [];
const mailboxPath = (0, SearchFieldParameters_1.getMailboxPathFromNodeParameter)(context, itemIndex);
const mailboxName = context.getNodeParameter('mailboxName', itemIndex);
let resultPath;
if (mailboxPath) {
resultPath = [mailboxPath, mailboxName];
}
else {
resultPath = mailboxName;
}
(_a = context.logger) === null || _a === void 0 ? void 0 : _a.info(`Creating mailbox "${resultPath}"`);
const mailboxCreateResp = await client.mailboxCreate(resultPath);
const item_json = JSON.parse(JSON.stringify(mailboxCreateResp));
item_json.operation = 'createMailbox';
item_json.mailboxName = mailboxName;
item_json.parentMailbox = mailboxPath || 'root';
item_json.fullPath = resultPath;
item_json.success = true;
item_json.createdAt = new Date().toISOString();
returnData.push({
json: item_json,
});
return returnData;
},
};
//# sourceMappingURL=MailboxCreate.js.map