This is an example of the small amount of work required to migrate an existing Twilio application to Bandwidth.
The original Appointment Reminders can be found over at Twilio's website.
Migration to Bandwidth for Appointment Reminders is VERY Easy
First thing is to update the Communications API to Bandwidth instead of Twilio
//var twilio = require('twilio');
var bandwidth = require('node-bandwidth');//var client = new twilio.RestClient(cfg.twilioAccountSid, cfg.twilioAuthToken);
var client = new bandwidth({
userId: cfg.bandwidthUserId,
apiToken: cfg.bandwidthAPIToken,
apiSecret: cfg.bandwidthAPISecret
});Bandwidth's methods each inherit from the base client class. So client.sendMessage becomes client.Message.send.
Bandwidth also uses text instead of body for the options.
var options = {
to: "+" + appointment.phoneNumber,
//from: cfg.twilioPhoneNumber,
from: cfg.bandwidthPhoneNumber,
//body: "Hi " + appointment.name + ". Just a reminder that you have an appointment coming up " + moment(appointment.time).calendar() +"."
text: "Hi " + appointment.name + ". Just a reminder that you have an appointment coming up " + moment(appointment.time).calendar() +"."
};
// Send the message!
//client.sendMessage(options, function(err, response) {...});
client.Message.send(options, function(err, response) {...});Be sure to update all your environment variables to include Bandwidth!
Take a look at the pull request on github.com for a breakdown on all the changes.