Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Sample of using Parse with the SendGrid Cloud Module. This example will send an email when other users comment on a picture in Anypic (https://parse.com/anypic).
// Require the SendGrid Cloud Module
var sendgrid = require("sendgrid");
sendgrid.initialize("you@parse.com", "your_password");
// Run this Cloud Function every time a new Activity (such as a comment)
// is saved
Parse.Cloud.afterSave("Activity", function(request, response) {
// Check if the activity type is a comment
var activity = request.object;
if (activity.get("type") === "comment") {
// Get the owner of the photo commented on
var targetUser = activity.get("toUser");
targetUser.fetch({
success: function(targetUser) {
// Send an email if we have the user's email
if (targetUser.get("email") && targetUser.get("email").length > 0) {
sendgrid.sendEmail({
to: targetUser.get("email"),
from: "anypic@parse.com",
subject: request.user.get("displayName") + " commented on your picture!",
text: "Check it out at anypic.org!"
}, {
success: function() {},
error: function() {}
});
}
},
error: function() {}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.