Skip to content

Instantly share code, notes, and snippets.

@tcr
Created October 28, 2011 02:18
Show Gist options
  • Save tcr/1321473 to your computer and use it in GitHub Desktop.
Save tcr/1321473 to your computer and use it in GitHub Desktop.
How do you use Twilio with Node.js on Heroku?
var TwilioClient, Twiml, app, config, express, phone, port, twilio;
express = require('express');
TwilioClient = require('./twilio').Client;
Twiml = require('./twilio').Twiml;
app = express.createServer(express.logger());
app.use(express.bodyParser());
config = {};
config.TWILIO_ACCOUNT_SID = 'your account sid';
config.TWILIO_AUTH_TOKEN = 'your auth token';
config.HOST = 'your.host.name';
twilio = new TwilioClient(config.TWILIO_ACCOUNT_SID, config.TWILIO_AUTH_TOKEN, config.HOST, {
express: app
});
phone = twilio.getPhoneNumber('+1' + '5555555555');
// Add your routes here...
port = process.env.PORT || 3000;
phone.setup(function() {
app.listen(port, function() {
return console.log("Listening on " + port);
});
return phone.on('incomingSms', function(reqParams, res) {
return onIncomingSMS(reqParams, res);
});
});
["heroku","twilio","node.js"]
@dynamicworkplace
Copy link

It looks as though node-twilio is no longer available at the URL you have given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment