Skip to content

Instantly share code, notes, and snippets.

@thomseddon
Created September 15, 2014 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomseddon/e2f614ac183996f7cdfa to your computer and use it in GitHub Desktop.
Save thomseddon/e2f614ac183996f7cdfa to your computer and use it in GitHub Desktop.
SupportBee <3 PagerDuty
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: 'trigger-name@company.pagerduty.com',
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());
}
@eurica
Copy link

eurica commented Sep 16, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment