ukd1 / node-twilio

A (deprecated) Twilio helper library for node. Use the official one:
https://github.com/twilio/twilio-node
177 stars 56 forks source link

Is there any way to have one service listen for multiple numbers? #13

Closed drewlesueur closed 7 years ago

drewlesueur commented 13 years ago

Is there a way to handle more than one phone number?

maybe someting like var phone = client.getPhoneNumber('+16269239971', '+14804444444');

gfosco commented 12 years ago

One way is to stop node-twilio from handling your provisioning URL's and handle those requests with your normal page router... I'm currently working on the same issue. I've all but removed AutoUri from the code, and need to finish. Unfortunately, it means separating some of the call logic.

i.e. in my apps twilio module:

var client = new twilioClient('sid','token','host');
exports.client = client;
var client2 = new twilioClient('sid','token','host');
exports.client2 = client2;

var phones = {};
phones['1234567890'] = client.getPhoneNumber('+11234567890');
phones['2345678901'] = client2.getPhoneNumber('+12345678901');
exports.phones = phones;

exports.twiML = twiML;

Then in my main server file, I use my router ("Choreographer") to handle inbound requests (to either number, since this is the URL configured on Twilio for both numbers.)

router.post('/inboundText', function(req, res) {
var formData = "";

req.on('data', function(data) {
    formData += data;
});
req.on('end', function() {
    formData = qs.parse(formData);
    console.log(formData);
    });
});
drewlesueur commented 12 years ago

Yea. I ended up just using the underlying api (in lib/rest-client.js and lib/twiml.js) and handled the routing myself. :)

ukd1 commented 7 years ago

This library is deprecated in favor of the official library - https://github.com/twilio/twilio-node