Venn Email

Build in a redundant messaging service seamlessly. If your email, sms or push notification provider goes down, we'll fall back to a secondary service.
Installation
npm install venn-messaging
Email
initialize(api_key)
params |
type |
description |
example |
api_key |
String |
Venn API Key |
64d2fa24h3f6f7cc61asp3e8 |
send(data, callback)
params |
type |
description |
example |
data.from |
String |
from email address |
from@email.com |
data.to |
String |
to email address |
to@email.com |
data.subject |
String |
email subject |
Subject 123 |
data.message |
String |
email message |
How you doin? |
Example
vennEmail = require("venn-messaging").Email;
// initialize and send an email
vennEmail.initialize(VENN_API_KEY);
var data = {
from: "from@email.com",
to: "to@email.com",
subject: "Subject 123",
message: "How you doin?"
};
vennEmail.send(data, function(err, result){
// email successfully sent if no error
});
SMS
initialize(api_key)
params |
type |
description |
example |
api_key |
String |
Venn API Key |
64d2fa24h3f6f7cc61asp3e8 |
send(data, callback)
params |
type |
description |
example |
data.from |
String |
from phone number |
+14354402246 |
data.to |
String |
to phone number |
+1633050227 |
data.message |
String |
text message |
How you doin? |
Example
vennSms = require("venn-messaging").SMS;
// initialize and send an SMS
vennSms.initialize(VENN_API_KEY);
var data = {
from: "+14356650499",
to: "+14503350029",
message: "How you doin?"
};
vennSms.send(data, function (err, result) {
// text successfully sent if no error
});
Push Notification
initialize(api_key)
params |
type |
description |
example |
api_key |
String |
Venn API Key |
64d2fa24h3f6f7cc61asp3e8 |
send(data, callback)
params |
type |
description |
example |
data.deviceToken |
String |
id of target device |
FE66489F304DC75B8D6E8200DFF8 |
data.deviceType |
String |
type of target device |
ios |
data.message |
String |
notification message |
How you doin? |
Example
vennPush = require("venn-messaging").Push;
// initialize and send a push notification
vennPush.initialize(VENN_API_KEY);
var data = {
deviceToken: "FE66489F304DC75B8D6E8200DFF8",
deviceType: "ios",
message: "How you doin?"
};
vennPush.send(data, function (err, result) {
// push notification successfully sent if no error
});
Development
Install Dependencies
npm install
Export Environment Variables
VENN_API_KEY="h41fa6602663b30c78b9c339"
VENN_API_URL="http://localhost:3400/v1"
Run Examples
node examples/example.js
Run Examples with Debugging
VENN_API_KEY=5f6abf85d1947ce29ce7332f
VENN_API_URL=http://localhost:3400/v1
DEBUG="venn"
node examples/example.js
Run Tests
mocha
Adding a New Service Provider
- Write Failing Tests
- Create a new test file of the form
test/service_type/service_name/error.js
- Copy
test/template/test_service_template.js
into this new file
- Follow instructions in the template file to create tests for the new service
- Create the New Service Provider
- Install the service provider's npm package as a dependency
- Create a new file of the form
lib/models/providers/service_type/service_name.js
- Copy
lib/models/providers/template/service_template.js
into this new file
- Follow instructions in the template file to create the new service
- Edit
lib/models/messaging_client.js
- Require the newly created service provider
var ServiceName = require('./providers/service_type/service_name');
- Add the newly created service provider to
initServices
else if (property === "service_name" && keys[property]) {
messagingProvider = new ServiceName(keys[property]);
}
- Add api key validator to Venn API