telcom

Abstraction layer between Twilio and Plivo.

Telcom Node.js

Node.js library for abstracting the difference between Twilio and Plivo. To start only sms is going to be supported.

telcom is available as an npm package. Install the latest version with:

npm install telcom
 
var TelcomClient = require('telcom');
 
var client = new TelcomClient({
  provider : 'twilio',
  sid : 'ACCOUNT_SID',
  token : 'AUTH_TOKEN'
});
 
 
client.sms({
  to : "+15551234567",
  from : '+15551234568',
  body : 'Hello from Telcom'
},function(error,ret){
  if(error){
    console.log("Failed to send message")
  }else{
    console.log("Message Sent")
  }
});
 

Telcome provides a few methods for validating and normalizing the requests from both Plivo and Twilio. These methods currently only support Express but could be modified slightly in the future to all other frameworks.

 
// Add the middleware to validate request from Provider 
app.use(TelcomClient.expressValidate())
 
// Add route with telcom.onSms handler to normalize data. 
app.get('/phone/sms',TelcomClient.onSms(function(req,res,sms){
 
  /* sms
  {
    to : '+15557894561',
    from : '+15557894561',
    body : 'This is a text',
    _clientReques : <Object> of original request.
  }
  */
 
  // Handle normal logic 
 
}));
 
  • Twilio - twilio
  • Plivo - plivo

telcom is licensed under the MIT License.