-
-
Save mathetos/fcb8dc34dcbebfdb23c1b92479878d1e to your computer and use it in GitHub Desktop.
Get Unassigned from HelpScout
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
/* | |
* HelpScout Zap: Get Number of Unassigned in a Specific Mailbox | |
* Use Zapier's "Code" Action to trigger this | |
* This only works with Zapier, it depends on the "callback" functions | |
*/ | |
var btoa = function (str) {return new Buffer(str).toString('base64');}; | |
fetch('https://api.helpscout.net/v1/mailboxes/{HELPSCOUT_MAILBOX_ID}/folders.json', { | |
cache: 'no-cache', | |
credentials: 'same-origin', | |
headers: { | |
"Authorization": "Basic " + btoa('{HELPSCOUT_API_KEY}:X') | |
}, | |
mode: 'no-cors', | |
}) | |
.then(function(res) { | |
return res.json(); | |
}) | |
.then(function (body) { | |
var output = { | |
name: body.items[0].name, // Returns 'Unassigned' | |
totalCount: body.items[0].totalCount // Returns int | |
}; | |
callback(null, output); | |
}) | |
.catch(callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment