Last active
February 15, 2019 19:11
-
-
Save csanz/99b0a96f28399dd901bffcb57a9921d5 to your computer and use it in GitHub Desktop.
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
/* | |
Some suodo code snippets for superhuman future API | |
To run code: | |
[COMMAND] + K | |
- Connect github repo | |
- View/Edit CRON jobs | |
- View history/logs | |
*/ | |
// Send follow up emails to sent messages | |
super.sentEmails.last(30).days(function(emails){ | |
for (var i = 0; i < emails.length; i++) { | |
// If email has not been opened, send first follow up | |
// Check that you don't send duplicate follow ups | |
if(!emails[i].opened && | |
!emails[i].sentFollowUps.length && | |
emails[i].originalEmailSent(2).daysAgoOrGreater() && | |
emails[i].hasLabel("INVESTOR")){ | |
super.snippet("1ST-FOLLOW-UP-TEMPLATE2").sendReply(emails[i]) | |
} | |
} | |
} | |
// Send update follow up message to someone on the list if they haven't responded | |
CRON monthly super.listen.email.inside(super.pluggin.google.load('DOCID',{c:'A'}),function(user){ | |
if (user.hasNotResponded(2).weeksAgo()){ | |
super.snippet("INVESTOR-FOLLOWUP-TEMPLATE").send(user) // replace tags $USER, $NAME | |
} | |
}) | |
// Admin cron job to send me a report of all emails | |
CRON monthly super.admin.emails.opened.last(30).days(function(emails){ | |
var content = "" | |
for (var i = 0; i < emails.length; i++) { | |
if(email.opened.length){ | |
content += email.subject + "\n" | |
for (var i = 0; i < email.opened.length; i++) { | |
content += "\t >" + email.opened[i].from.name | |
} | |
} | |
} | |
super | |
.admin | |
.schedule | |
.email(super.snippet("OPENED-EMAILS-REPORT") | |
.send(super.me,content)) | |
}) | |
// Send update email if | |
super.plug.google.load('DOCID',function(data){ | |
data.filter({columns:['A','B','C'], rows:[1,100]}).function(data_filtered){ | |
for (var i = 0; i < data_filtered.length; i++){ | |
// Date of last contact (from col A) | |
if(super.date(data_filtered[i].col('A').val).isGreaterThan(5).days()){ | |
// Send email if the last contact was greater than 5 days | |
super | |
.snippet("INVESTOR-UPDATE-TEMPLATE1") | |
.send(data_filtered[i].col('B'),data_filtered[i].col('C')).delay(4).hours() | |
// Update (only updates if message sent successfully | |
data_filtered[i].col('A').update(super.date.now) | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment