Rich incidents demo 1
Show a live graph
by eurica
HTML
<script src="https://eurica.github.io/pdjs/js/pdjs.js"></script>
<!--
This is a simple example that uses rich incidents in the PagerDuty integration API to send an incident with a link to a conference call.
Put one of your service keys in the form on the lower right and trigger an incident to see an embeded image and links to a phone conference.
- It uses https://github.com/eurica/pdjs
- For more details on triggering an incident, https://developer.pagerduty.com/documentation/integration/events/trigger
Please contact [email protected] with any questions
-->
<form>
<table border=0>
<tr>
<td>Service Key:</td>
<td>
<input type="text" size="50" placeholder="56debc0c07a8492b89cd78a2d29785a3" id="servicekey" value="56debc0c07a8492b89cd78a2d29785a3" />
</td>
</tr>
<tr>
<td>Description:</td>
<td>
<input type="text" value="Urgent Conference Call" size="50" id="description" />
</td>
</tr>
<tr>
<td>Name:</td>
<td>
<input type="text" value="Conference Bridge" size="50" id="phonename" />
</td>
</tr>
<tr>
<td>Number:</td>
<td>
<input type="text" value="16508003625" size="50" id="phonenumber" />
</td>
</tr>
<tr>
<td>Trigger incident:</td>
<td>
<input type="button" value="Click to trigger incident" onclick="PDTrigger()" />
</td>
</tr>
</table>
</form>
JavaScript
$ = jQuery;
PDJS = new PDJSobj();
function PDTrigger() {
service_key = $("#servicekey").val()
description = $("#description").val()
phonename = $("#phonename").val()
phonenumber = $("#phonenumber").val()
contexts = [{
"type": "link",
"href": "skype:"+phonenumber,
"text": "Call "+ phonename + " via Skype"
}, {
"type": "link",
"href": "tel:"+phonenumber,
"text": "Call "+ phonename + " via phone"
}]
incident = {
incident_key: Date.now(),
service_key: service_key,
description: description,
details: {},
data: {
contexts: contexts
},
success: function (json) {
alert(JSON.stringify(json))
console.log(json)
}
}
console.log(incident)
t = PDJS.trigger(incident);
console.log(t)
}