sendgrid-scheduler

A SendGrid Scheduler App


Keywords
sendgrid, job, schedule, emails
License
MIT
Install
npm install sendgrid-scheduler@0.0.1

Documentation

SendGrid Scheduler

REST API for scheduling mails with Sendgrid API using Node.js and Express.js framework with DiskDB.

A Job Scheduler that tasks up emails to be sent in future with a timestamp as input. Also added support for template engine of SendGrid Console.

Running project

You need to have Node.js installed.

1) Install dependencies

To install dependencies enter project folder and run following command:

npm install

2) Run server

To run server execute:

node .

EndPoints

HTTP METHOD METHOD
/schedule GET
/schedule/:scheduleId GET
/schedule/create/ POST

Inputs

NAME INFO REQUIRED
apiKey SendGrid API Key Yes
to Receiver's email Yes
from Sender's email Yes
subject Email Subject Yes
scheduleAt Timestamp when mail should be sent e.g 1411820580000 Yes

For Standard Mails

NAME INFO REQUIRED
text Email Text/Contents Yes

For Template Mails

NAME INFO REQUIRED
template_id Your SendGrid Template Id Yes
substitution name 1. E.g -name- No
substitution name 1. E.g -address- No
and so on No

Example Request

POST /schedule/create

Post Variable Array Fields:

  • apiKey:SG.s2Ylltj-Sj-aXiRRwnbx9yMfqmo-qha@@
  • to: test@example.com
  • from: test@test.com
  • subject:test
  • text:test
  • template_id: 5c3df864-d983-42aa-a9b6-cbbdeedbc98c
  • scheduleAt: 1471637160000
  • booking_id:lkjh
  • link:hklj
  • title:hjkl
  • name:test

Response body:

{  
"status":200,
"message":"A new mail has been successfully saved and scheduled",
"schedule":{  
  "apiKey":"SG.s2Ylltj-Sj-aXiRRwnbx9yMfqmo-qha@@",
  "to":"test@example.com",
  "from":"test@test.com",
  "subject":"test",
  "text":"test",
  "scheduleAt":"1471637160000",
  "booking_id":"lkjh",
  "link":"hklj",
  "title":"hjkl",
  "start_time":"lhjk",
  "end_time":"jlhk",
  "tariff":"hjkl",
  "hours":"hjkl",
  "tax":"hjkl",
  "total":"jhkl",
  "status":"hjkl",
  "template_id":"5c3df864-d983-42aa-a9b6-cbbdeedbc92c",
  "name":"test",
  "isCompleted":false,
  "_id":"aaec631936e94559b210b7197661c45e",
  "mailJob":{  
     "name":"job_mail_aaec631936e94559b210b7197661c45e",
     "reminderId":"aaec631936e94559b210b7197661c45e",
     "_id":"f5539cadb7634cb8bcb5e094d06e8690"
  }
    }
        }    

Author

This module was created by Karan K

License

MIT