Last active
July 23, 2020 12:04
-
-
Save sheharyarn/fb7db10c1bf67a22d585879bcd11775a to your computer and use it in GitHub Desktop.
Google Appscript to auto-reply to recruiters
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
function respondToEmails() { | |
//var filter = 'from:([email protected]) AND -label:"Auto-Replied"'; | |
var filter = 'label:"Job Proposals" AND -label:"Auto-Replied"'; | |
var completeLabel = GmailApp.getUserLabelByName("Auto-Replied"); | |
var threads = GmailApp.search(filter); | |
var replyFrom = "Recruiter Bot <[email protected]>"; | |
val realEmail = "[email protected]" | |
var formLink = "https://link.to/your/form" | |
var response = ( | |
"Hello, dear recruiter!" + | |
"\n\n<br/><br/>" + | |
"Thank you for getting in touch! I receive a lot of job proposals, " + | |
"so I have a form to collect all the important information for me. Please " + | |
"click the link below and spend a few minutes describing the job. " + | |
"That will help me get all the data I need:" + | |
"\n\n<br/><br/>" + | |
"<code>" + formLink + "</code>" + | |
"\n\n<br/><br/>" + | |
"Best Regards," + | |
"\n<br/>" + | |
"<b>Sheharyar Naseer</b>" + | |
"\n\n<br/><br/>" + | |
"---" + | |
"\n\n<br/><br/>" + | |
"<i>Did the bot incorrectly categorize you as a recruiter? If so, you can send me an email directly at: " + realEmail + "</i>" + | |
"\n\n<br/><br/>" | |
); | |
for (var i = 0; i < threads.length; i++) { | |
var subject = threads[i].getFirstMessageSubject(); | |
var id = threads[i].getId(); | |
Logger.log("[New Email Found]: " + id + "(" + subject + ")"); | |
threads[i].reply("", {htmlBody: response, from: replyFrom}); | |
threads[i].addLabel(completeLabel) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment