Last active
January 21, 2026 17:12
-
-
Save peppy/696d6a9df7036a11fce21252101684df to your computer and use it in GitHub Desktop.
zendesk spam filter
This file contains hidden or 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
| /* | |
| * This will let you action on all zendesk emails. | |
| * Unfortunately this isn't as they arrive, but on a time based schedule. | |
| * It will help with organisation but not stop realtime notifications from arriving. | |
| * | |
| * - Create a new app/script on https://script.google.com. | |
| * - Setup a time based trigger (1 hour works well for me) | |
| * - Run the following function: https://gist.github.com/peppy/696d6a9df7036a11fce21252101684df. | |
| * - IMPORTANT: it currently adds a label which you can then use to filter and manually action on emails. | |
| * If you prefer, you can archive or trash automatically (see commented lines at the end of the code), | |
| * BUT make sure you understand that this will affect all zendesk emails, including support tickets that | |
| * you may genuinely want to read. | |
| */ | |
| function handleZendeskSpam() { | |
| const label = GmailApp.getUserLabelByName("zendesk"); | |
| const threads = GmailApp.search('-label:zendesk newer_than:1d'); | |
| const matches = []; | |
| threads.forEach(t => { | |
| if (/X-Mailer:.*zendesk/i.test(t.getMessages()[0].getRawContent())) { | |
| matches.push(t); | |
| } | |
| }); | |
| if (matches.length) { | |
| label.addToThreads(matches); | |
| // GmailApp.moveThreadsToArchive(matches); | |
| // GmailApp.moveThreadsToTrash(matches); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment