Created
September 15, 2014 18:23
-
-
Save thomseddon/e2f614ac183996f7cdfa to your computer and use it in GitHub Desktop.
SupportBee <3 PagerDuty
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
function doPost(req) { | |
var date = new Date(); | |
var hour = date.getHours(); | |
var day = date.getDay(); | |
// Normal support | |
if (hour >= 9 && hour <= 17 && day >= 1 && day <= 5) | |
return ContentService.createTextOutput('Normal support'); | |
// Parse body | |
var data = JSON.parse(req.postData.contents).payload; | |
// Only handle creations | |
if (data.action_type !== 'ticket.created') | |
return; | |
// Initiate pagerduty | |
MailApp.sendEmail({ | |
to: '[email protected]', | |
subject: '#' + data.ticket.id + ': ' + data.ticket.subject, | |
body: [ | |
data.ticket.requester.name + ' <' + data.ticket.requester.email + '>', | |
data.ticket.subject, | |
data.ticket.content.text, | |
'', | |
'Opened at: ' + data.ticket.created_at, | |
'Link: https://company.supportbee.com/tickets/' + data.ticket.id, | |
'', | |
].join('\n'), | |
noReply: true | |
}); | |
return ContentService.createTextOutput('OOH @ ' + date.getHours()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you were hitting the REST trigger API you could send a client/client_url and link directly from the incident in PD. http://developer.pagerduty.com/documentation/integration/events/trigger