Add Note Automation Processor
Overview
The Add Note automation creates CRM notes on deals when they enter a specific pipeline stage. It tracks activity and logs notes for audit trail.
Source File: queue-manager/queues/deals/automations/note.js
Triggered By: queue-manager/services/deals/automations.js
Business Impact: MEDIUM - Deal documentation
Processing Logic
sequenceDiagram
participant AUTO as Automation Service
participant QUEUE as Note Queue
participant DEAL as Deals
participant NOTE as CRM Notes
participant ACTIVITY as Activity Log
AUTO->>QUEUE: Add automation job
QUEUE->>DEAL: Find eligible deals
loop For Each Deal
QUEUE->>NOTE: Create note
NOTE-->>QUEUE: Note ID
QUEUE->>ACTIVITY: Log note activity
QUEUE->>DEAL: Mark automation triggered
end
Key Features
Note Creation
const note = await new CRMNote({
account: accountID,
created_by: userID,
content: automation.data.content,
deal: dealID,
type: 'deal',
}).save();
Activity Logging
const activityData = {
activity_type: 'note',
auth: {
account_id: accountID,
uid: userID,
account: { is_owner: false },
},
data: {
type: 'deal',
deal_id: dealID.toString(),
activity_details: noteID.toString(),
},
};
await addActivity(activityData.data, false, activityData.activity_type, activityData.auth);
Collections Used
Input: deal-automation
Query: deal
Create: crm-note
Create: activity
Use Cases
Example: Stage Entry Note
// Automation
{
stage_id: "qualified",
action: "add_note",
data: {
content: "Lead has been qualified and moved to qualified stage by automation"
},
delay: 0
}
Performance
Execution Time: 200-500ms per deal
Complexity: LOW
Lines of Code: 175