Skip to content

Instantly share code, notes, and snippets.

@sagnew
Last active August 2, 2018 19:53
Show Gist options
  • Save sagnew/586c92eed20ea0ee31f9cba72c4e7232 to your computer and use it in GitHub Desktop.
Save sagnew/586c92eed20ea0ee31f9cba72c4e7232 to your computer and use it in GitHub Desktop.
Twilio Node API Demo
// The Twilio Node library checks the environment variables
// 'TWILIO_ACCOUNT_SID' and 'TWILIO_AUTH_TOKEN' by default when instantiating a client object.
const client = require('twilio')();
const numbers = new Set()
client.messages.each({
to: '+12019497446',
}, (message) => {
if (!numbers.has(message.from)) {
numbers.add(message.from);
client.calls.create({
to: message.from,
from: '+12019497446',
url: 'https://handler.twilio.com/twiml/EH458781dde69bba9ebb85cd93185098a7'
})
.then(call => console.log(call.sid));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment