A platform which serves user with the ability to send email campaigns to their customers.
Create Campaign
- User creates a campaign with a start and end date. (timeline)
- A new batch entry is created in the batch table and the batch_id is added to the new campaign obj.
Upload Contacts
- User provides with a csv file which contains name and email of the customers.
- A batch_id is assigned to each customer
- A subsequent entry is made into the batch table with the object ids of all the new contact objs
_id, recipient:['1232gn12j1', '122rdg12j1']
Create Scenario
- User creates a scenario providing with the following info:
- Subject: Plain text
- Content: Plain text
- Date
- Time at which to send the email
- Assigns the scenario to a campaign
List Scenario and Campaign
- User can view added campaigns and scenarios as a list
A cron script runs daily at 6:00 am which basically runs the scheduler.
The scheduler does the following tasks order wise.
- List all active campaigns, calculating by the start and end date(timeline).
- If an active campaign is present, it then list all the scenarios, of these active campaigns, which are scheduled for the day.
- If any scenario is present it then runs the following series of task for each scenario
- Gets the campaign obj using the campaign_id present in the scenario obj.
- Using the campaign obj it gets the batch_id
- An entry is made into the
emailer
table with the batch_id, scenario_id and campaign_id, and the time at which the current scenario is scheduled to run. - The newly made
emailer entry
is marked asactive:true
andsent:false
- Once the entry is made, a cron script is then scheduled to run at the time specified in the scenario.
emailer
_id
is passed into each cron script.
The cron script schduled to run for a scenario performs the following tasks.
- Using the emailer_id it first gets the emailer obj
- batch_id present in the emailer obj is then used to fetch the batch obj
- Similarily, scenario_id present in the emailer obj is used to fetch the scenario obj
- Now using the batch obj fetched, all contacts are listed using
recipient array
present in the batch obj - Finally, phew, For each contact:
- An email is sent to the customer using scenario content and subject.
- An unsubscribe link is sent along with the content.
- Once the email is sent, the emailer entry is marked is
active:false
andsent:true
- The scenario obj is updated with the number of contacts served.
- core -> backend
- web -> frontend