Created
September 20, 2018 17:26
-
-
Save mrlynn/edde6583363e9dbac63ad7d3d3f17518 to your computer and use it in GitHub Desktop.
Send an SMS Text Message with MongoDB Stitch
This file contains 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
exports = function(message) { | |
const mongodb = context.services.get("mongodb-atlas"); | |
const coll = mongodb.db("db").collection("users"); | |
const twilio = context.services.get("my-twilio-service"); | |
const yourTwilioNumber = context.values.get("twilioNumber"); | |
coll.find().toArray().then(users => { | |
users.forEach(user => twilio.send({ | |
to: user.phone, | |
from: yourTwilioNumber, | |
body: message | |
}) | |
); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment