Skip to content

Instantly share code, notes, and snippets.

@takus

takus/ic.coffee

Created Jul 5, 2016
Embed
What would you like to do?
Manage incidents with Incident Commandar System.
# Description:
# Manage incidents with Incident Commandar System.
# Commands:
# bot 110 ic me - Start an incident management and assign 'me' as the Incident Commandar
moment = require('moment')
module.exports = (robot) ->
robot.respond /110 ic me/i, (res) ->
userId = res.envelope.user.id
userName = res.message.user.name
date = new Date
incident = {
"ic": "",
"cl": "",
"startDate": date,
"severity": 5,
"title": "",
"status": []
}
incident.ic = userId
robot.brain.set "incident", incident
res.send """
EMERGENCY STARTED BY <@#{userName}> AT #{date}
> <@#{userName}> is now the Incident Commandar:
> * Use `bot 110 set title` to set/update the incident title in Upboard
> * Use `bot 110 set status` to set/update the incident status
> * For next steps, Consul the IC checklist: http://fakechecklisturl.com
"""
robot.respond /110 cl me/i, (res) ->
userId = res.envelope.user.id
userName = res.message.user.name
date = new Date
incident = robot.brain.get "incident" || {}
incident.cl = userId
robot.brain.set "incident", incident
res.send """
> <@#{userName}> is now the Communication Lead:
> * For next steps, consul with the Support playbook: http://fakeplaybook.com
> * See the gudelines for posting site status: http://fakegudelines.com
> * Log into Internal Status Page and sent initial internal comms: http://fakesignin.com
"""
robot.respond /110 set title (.+)\s*$/i, (res) ->
title = res.match[1]
incident = robot.brain.get "incident" || {}
if incident.title != title
incident.title = title
robot.brain.set "incident", incident
res.send """
*Title changed:*
#{title}
"""
robot.respond /110 set status (.+)\s*$/i, (res) ->
status = res.match[1]
incident = robot.brain.get "incident" || {}
incident.status.push {"eventDate": new Date, "status": status}
robot.brain.set "incident", incident
res.send """
*Status changed:*
#{status}
"""
robot.respond /110 over$/i, (res) ->
userId = res.envelope.user.id
userName = res.message.user.name
date = new Date
incident = robot.brain.get "incident" || {}
incident.endDate = date
duration = moment.duration(incident.endDate - incident.startDate)
res.send """
EMERGENCY ENDED BY <@#{userName}> IN #{duration.humanize().toUpperCase()} (STARTED: #{incident.startDate})
"""
ic = robot.brain.data.users[incident.ic]
cl = robot.brain.data.users[incident.cl]
incident_timeline = ""
for s in incident.status.reverse()
incident_timeline += "- #{s.eventDate} #{s.status}\n"
res.send """
<@#{ic.name}>: You should:
* update the incident report in Upboad: http://upboard.com
```
# #{incident.title}: #{incident.startDate}
Incident management info: http://incident-management-cheat-sheet
## Summary
TODO: Write incident summary here
## Members
| Role | Slack Name | Full Name |
|:-------------------|:-----------|:----------------|
| Incident Commander | #{ic.name} | #{ic.real_name} |
| Communication Lead | #{cl.name} | #{cl.real_name} |
## Incident timeline (most recent first)
#{incident_timeline}
```
"""
res.send """
<@#{cl.name}>: You should:
* Consul with CM about resolving external communications and component statuses.
* Write (and get approved by the CM) a Resolved internal status page message.
* Ask IC for a list of affected customers. Send this list to fake@newrelic.com. KAMs may also use http://fakecsv.com to pull a CSV.
* Ensure Customer Communications information is added to Upboard: http://upboard.com.
"""
robot.brain.remove "incident"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.