Skip to content

Instantly share code, notes, and snippets.

@MarcusHurney
Created January 12, 2017 21:26
Show Gist options
  • Save MarcusHurney/aa2d963e2ffce355ba1e7fb15f304cb2 to your computer and use it in GitHub Desktop.
Save MarcusHurney/aa2d963e2ffce355ba1e7fb15f304cb2 to your computer and use it in GitHub Desktop.
async.each(myContacts, function(contact, messageToSend, callback) {
const message = {
from: "+18442849820",
to: `+1${contact.number}`,
text: messageToSend,
callbackUrl: 'https://happie-match.herokuapp.com/messageCallback'
};
client.Message.send(message)
.then(function(message) {
console.log("Message sent with ID " + message.id);
callback();
})
.catch(function(err) {
console.log(err.message);
callback(err);
});
}, function(err) {
if( err ) {
// One of the iterations produced an error.
// All processing will now stop.
console.log('There was an error sending SMS');
console.log(err);
} else {
console.log('All SMS sent');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment