Create a gist now

Instantly share code, notes, and snippets.

Sample of using Parse with the SendGrid Cloud Module. This example will send an email when other users comment on a picture in Anypic (
// Require the SendGrid Cloud Module
var sendgrid = require("sendgrid");
sendgrid.initialize("", "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");
success: function(targetUser) {
// Send an email if we have the user's email
if (targetUser.get("email") && targetUser.get("email").length > 0) {
to: targetUser.get("email"),
from: "",
subject: request.user.get("displayName") + " commented on your picture!",
text: "Check it out at!"
}, {
success: function() {},
error: function() {}
error: function() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment