Last active
August 2, 2018 19:53
-
-
Save sagnew/586c92eed20ea0ee31f9cba72c4e7232 to your computer and use it in GitHub Desktop.
Twilio Node API Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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