ukd1 / node-twilio Goto Github PK
View Code? Open in Web Editor NEWA (deprecated) Twilio helper library for node. Use the official one:
Home Page: https://github.com/twilio/twilio-node
A (deprecated) Twilio helper library for node. Use the official one:
Home Page: https://github.com/twilio/twilio-node
I was needing more flexibility for specifying the protocol (http/https) and port (80/443) for the callback URI, so I simplified the whole process by just passing an entire URL string into lib/auto-uri.js
I updated the rest of the project accordingly. See this commit in my fork:
I wanted to solicit opinions on this before I make a pull request.
Thanks everyone!
This node library set up the URL's automatically to be POST but does not change the URL settings on twilio to use POST instead of GET, leading to 500's because no route matches.
I'm trying to get it to just forward the call -- not sure what I'm doing wrong here:
phone.setup(function() {
phone.on('incomingCall', function(reqParams, res) {
console.log("New Call:");
var dial = new Twiml.Dial({Number: new Twiml.Num("+15555555"), callerId: "+15555555"});
res.append(dial);
res.send();
});
});
Twilio is saying app error but I'm not seeing anything in my logs -- perhaps a timeout. Do I need to listen for the answered event or am I just getting the Twiml API wrong?
Thanks!
This library is incompatible with hosting platforms like Heroku and Joyent, which provide you with a specific port in which to listen. The AutoUri lib makes it necessary to have an additional port open for Twilio requests. Apps therefore crash on startup.
Can the library accept an existing express instance, and add endpoints to it?
I there I have this code
phone.on('incomingSms', function(smsParams, response) {
console.log("REQUEST:");
console.log(smsParams);
var from = smsParams.From;
...
});
And when I get a response I see this in my logs
012-01-20T00:00:41+00:00 app[web.1]: REQUEST:
2012-01-20T00:00:41+00:00 app[web.1]: undefined
2012-01-20T00:00:41+00:00 app[web.1]: TypeError: Cannot read property 'From' of undefined
Am I doing something wrong? This seems like the exact way the docs do it.
Thank you!
Link is not working anymore
Demo accounts (free credit on twilio.com) are not allocated OutgoingNumbers, so client.getPhoneNumber() fails even though there are numbers registered which work for outgoing calls with the REST api, this also means that the registration of incoming events not associated with outgoing calls is automatic which may not be desired.
Proposed fix: add a getOutgoingNumber() call to match getPhoneNumber() which does not register the incoming number callbacks, other wise the API would be unchanged. This may require an additional parameter to the PhoneNumber constructor which is an internal object and not exported.
Hey,
I was able to launch my app but I notice its reallly slow right now. Looking at the logs I see:
2012-01-20T02:10:47+00:00 heroku[router]: Error H12 (Request timeout) -> POST morning-dawn-8986.herokuapp.com/autoprovision/58 dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
2012-01-20T02:10:47+00:00 heroku[router]: Error H12 (Request timeout) -> POST morning-dawn-8986.herokuapp.com/autoprovision/57 dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
2012-01-20T02:10:48+00:00 heroku[router]: Error H12 (Request timeout) -> POST morning-dawn-8986.herokuapp.com/autoprovision/59 dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
What are these requests ment to be doing, and should they be timing out (and slowing things down) like this?
No updates in a year, pull requests and issues piling up. Just curious. I have an eval account for Twilio and I'm not sure I want to go premium if the node client isn't actively supported.
After every "incomingCall" event the twilio debugger gets populated with the following error:
ERROR HTTP connection failure
An attempt to retrieve TwiML from
http://4iif.localtunnel.com/autoprovision/3
failed; the connection timed out. Please check the URL and your network settings and try again.
And according to Request it looks like a call status data
I'm wondering which event I should listen to to omit this error?
e.g. for outgoing call I must be listening to "ended" even to omit another similar issue, but it didn't help with incomingCall event...
Thanks.
You have no express
dep in your package.json file.
You also don't specify which version of express you require. I tried to install the latest express and run your demos, but all I get is:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object # has no method 'bodyDecoder'
at new AutoUri (/Users/maraksquires/dev/hook.io-twilio/node_modules/twilio/lib/auto-uri.js:32:17)
at new Client (/Users/maraksquires/dev/hook.io-twilio/node_modules/twilio/lib/twilio.js:18:15)
at Object. (/Users/maraksquires/dev/hook.io-twilio/test.js:3:15)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array. (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)
In playing around with this library I am starting by trying to send SMS. Following the SMS example I am getting an error thrown at
var phone = client.getPhoneNumber('+XXXXXXXXXX');
The number is a full "upgraded" Twilio number and testing the REST API with CURL indicates it works fine. Starting to dig into the library some now to see if I can find where the issue lies. Any help or suggestions would be appreciated.
Full Error:
/home/chad/twilio2factor/node_modules/twilio/lib/twilio.js:141
throw new Error('Could not get number ' +
^
Error: Could not get number +4154187543
at /home/chad/twilio2factor/node_modules/twilio/lib/twilio.js:141:27
at IncomingMessage. (/home/chad/twilio2factor/node_modules/twilio/lib/rest-client.js:87:40)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at CleartextStream.ondata (http.js:1228:22)
at CleartextStream._push (tls.js:303:27)
at SecurePair.cycle (tls.js:577:20)
at EncryptedStream.write (tls.js:96:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
Hello,
I've just attempted to install the package with npm and I got the warning about 'modules' being deprecated. I think there's a new way of doing this in the later versions of node, and so the code has to be refactored slightly.
The version of node I'm running is the latest: 'v0.7.0-pre'
npm install twilio
npm http GET https://registry.npmjs.org/twilio
npm http 200 https://registry.npmjs.org/twilio
npm http GET https://registry.npmjs.org/twilio/-/twilio-0.4.0.tgz
npm http 200 https://registry.npmjs.org/twilio/-/twilio-0.4.0.tgz
npm WARN [email protected] package.json: 'modules' object is deprecated
[email protected] ./node_modules/twilio
I'm looking forward to giving this module a try!
bodyDecoder -> bodyParser
I don't see any way to get the next set of data with the twilioClient object. I'm calling getIncomingNumbers and have quite a few to pull down. I suppose I could just say:
client.getIncomingNumbers({ 'PageSize': 150 }, function(data) { .. });
But that doesn't really seem future proof.
Hey, this is my first twillio app ever and I am a newcomer to node as well so please forgive my ignorance. I'm trying to use the dial-list example you provided to create the application.
I keep on getting the following error:
Error: Could not get number +NNNNNNNNNN
I just tried to do the demo app after verifying my personal number on the twillio website. I used that number for the outgoing number in the config file. I'm confused about what I should put for the hostname. I tried to use my IP address but that didn't work. I would like to try things from my dev machine, rather than push to heroku or ec2 to see if things are working. Any advice?
Is there a way to handle more than one phone number?
maybe someting like var phone = client.getPhoneNumber('+16269239971', '+14804444444');
Can't seem to get calls to work using this demo, or the API it consumes: https://github.com/sjwalter/node-twilio/blob/master/examples/dial-list/app.js
Seems that the answered
event, or any other events are firing.
With the following code:
var phone_number = "12345";
var phone = client.getPhoneNumber(phone_number);
phone.setup(function() { })
If phone_number does not exist in your account, the following is thrown:
throw new Error('Could not get number ' +
^
Error: Could not get number 1234
at /Users/robert/colingo/Express/node_modules/twilio/lib/twilio.js:142:27
at IncomingMessage.<anonymous> (/Users/robert/colingo/Express/node_modules/twilio/lib/rest-client.js:86:41)
at IncomingMessage.emit (events.js:81:20)
at HTTPParser.onMessageComplete (http.js:133:23)
at CleartextStream.ondata (http.js:1231:22)
at CleartextStream._push (tls.js:303:27)
at SecurePair.cycle (tls.js:577:20)
at EncryptedStream.write (tls.js:96:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
I have found that putting try/catch around the call to phone.setup() does not actually catch the error.
Two questions:
1.) Why does my try/catch not work?
2.) Is there a better way to check that a number exists in an account?
What parameters does it take? Moreover, how do I receive the input back? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.