Campaigns Management
Relevant source files
The following files were used as context for generating this wiki page:
Campaigns Management in Send Again provides a structured environment for organizing, building, and analyzing automated email workflows. It allows users to define complex sequences of emails, delays, and conditional logic (Rules) based on recipient data or historical behavior. The system supports visual workflow construction, automated audience targeting, and granular performance tracking.
The module is integrated into the broader application ecosystem, utilizing core services such as Contact Management for recipient data and Event Tracking for behavioral triggers. Workflows are managed within the context of specific workspaces, ensuring data isolation and domain-specific configuration.
Sources: src/app/campaigns/page.tsx:1-50, README.md:10-25
Workflow Architecture
The campaign system utilizes a directed graph structure where various "Nodes" represent steps in the lifecycle of an email campaign. These nodes are connected by "Edges" that define the flow of execution based on specific ports.
Node Types
The system supports three primary types of workflow nodes:
| Node Type | Description | Key Properties |
|---|---|---|
| Send Node | Executes an email dispatch. | subject, html, from, audience |
| Delay Node | Pauses the workflow for a specific duration. | delayDays, delayHours |
| Rule Node | Evaluates conditions to branch the workflow. | matchMode, conditions |
Sources: src/app/campaigns/page.tsx:43-85, src/app/campaigns/page.tsx:162-180
Connection Logic
Nodes are linked via WorkflowEdge objects. Transitions depend on the source node type:
- Standard Transitions:
SendandDelaynodes use a singlenextport to proceed to the next step. - Conditional Transitions:
Rulenodes usetrueandfalseports to branch logic based on whether conditions are met.
Sources: src/app/campaigns/page.tsx:87-92, src/app/campaigns/page.tsx:210-220
The diagram above illustrates a typical sequence involving a time delay and a conditional branch based on user interaction.
Sources: src/app/campaigns/page.tsx:340-370
Audience and Rules Engine
The Campaigns Management system features a robust rules engine for targeting recipients. Audiences can be defined manually or through dynamic rules evaluated against contact fields and historical events.
Condition Types
- Field Condition: Matches against custom metadata or standard fields (e.g.,
verified) using operators likeequals,contains, ornotEquals. - History Condition: Triggers based on previous interactions (e.g.,
open,click,bounce) relative to a specific email subject.
Sources: src/app/campaigns/page.tsx:13-30, src/app/app/page.tsx:246-270
Logic Evaluation
Conditions are evaluated using a matchMode, which determines the logical relationship between multiple criteria:
- All: Every condition must be true (Logical AND).
- Any: At least one condition must be true (Logical OR).
Sources: src/app/app/page.tsx:290-310, src/app/campaigns/page.tsx:32-34
Performance and Analytics
Analytics are centralized to provide insight into campaign health and recipient engagement. Data is derived from Event Tracking via SNS webhooks.
Key Metrics
The system aggregates the following metrics for campaign subjects:
- Sent: Total volume of emails dispatched.
- Delivered: Success rate of delivery from SES.
- Opened/Clicked: Engagement rates calculated against delivered sends.
- Bounce/Complaint: Deliverability risk factors.
Sources: src/app/app/page.tsx:78-105, src/lib/db.ts:1095-1150
Visual Analytics: Sankey Diagram
A Sankey diagram is used to visualize the "flow" of recipients through various stages of engagement, from initial send to final click.
Sources: src/app/app/page.tsx:550-650
Data Persistence and Storage
Campaign drafts and saved workflows are persisted locally and in the backend database.
Storage Schema
Workflows are represented as JSON objects containing arrays of nodes and edges. The system supports migration from legacy schemas (v5 migration logic).
| Field | Type | Description |
|---|---|---|
campaignId | string | Unique identifier for the campaign. |
name | string | User-defined label for the workflow. |
nodes | WorkflowNode[] | Array of steps in the campaign. |
edges | WorkflowEdge[] | Connections between nodes. |
Sources: src/app/campaigns/page.tsx:94-110, src/app/campaigns/page.tsx:240-270
Backend Integration
The src/lib/db.ts file handles the underlying database operations, including fetching send history and aggregating campaign performance metrics used by the management interface.
Sources: src/lib/db.ts:1070-1200
Summary
Campaigns Management serves as the orchestration layer for Send Again. By combining a visual builder with a granular rules engine and behavioral analytics, it allows for sophisticated lifecycle marketing. The system's reliance on Amazon SES ensures high deliverability, while the flexible node architecture permits extensive automation patterns.
Sources: src/app/campaigns/page.tsx:1020-1040, README.md:5-15