Creating Custom Slack Commands

Building custom Slack commands is easy! You can run these commands directly from Slack to retrieve up-to-date information about your incident management process.

Megan Mooreprofile image

By Megan Moore on 4/15/2021

Site Reliability Engineers are expected to know everything that’s happening, all of the time. That’s a lot of things! To help you sift through the noise, we’ve developed a feature that lets you find accurate data about your organization on-demand. You can do this by sending custom-designed commands to FireHydrant directly from your integrated Slack account. 

FireHydrant's built-in commands

First, let’s look at the FireHydrant commands that are already built in. They address tasks you’d normally execute as you work your way through an incident. You can run handy commands like:

  • /fh new, which opens a dialogue box where you kick off a new incident

  • /fh on-call, which prompts you to pick a service, and then identifies the person on call for that service

  • /fh link, which links your Slack user account to FireHydrant (if you haven’t done so already)

Enter /firehydrant help in Slack to see the full menu (you can run the command in a direct message to yourself).

Customizing commands to improve your workflow

OK, so you know the built-in options. Now let’s get crafty. You can customize Slack commands to pull up whatever information you want, and you can use variables to ensure that your data is up to date every time you request it. Think of these custom commands (we call them Command Extensions) as tools to make Slack into your own personal command line for all things related to incident management. 

To get started, in the menu panel on the left side of the FireHydrant app, select Integrations > Connected & Available. Where your Slack integration is listed, click Configure Integration. This reveals your options for editing your Slack configuration. Scroll to the bottom of the page for the section on Command Extensions and click Add Command Extension. You can start with something simple; for example, a command to pull up your company’s logo. Provide the command name (“logo”) and a brief description of the resource (“our company logo”). In the Reply template field, provide a link to a page where your company logo is stored (like in a Google doc or Github). Then, when anyone in your organization runs the command /fh logo, FireHydrant returns the link to your logo page. 

How about something more customized? You can include arguments in your command to target unique data. FireHydrant uses template variables to reference incident-state data. For context, take a look at the FireHydrant API--every item on the incident entity is available as a variable. (If you run command extensions from an incident-specific Slack channel, a variable called incident becomes available. You can use this variable as you develop your custom commands.) So if, say, you want to find the names of your team members who are assigned to a specific role in an incident, you can use the incident.incident_roles variable with a for loop over it. This essentially tells FireHydrant, "for each of these roles, print out the name of the role assigned and the person assigned to it." Our templates are enabled with the Liquid language, which provides many operations you can execute on values. 

Let’s say you want to write a command extension that directs users to their next step inside an incident channel. We can call it /fh what-next. You can create a command that asks: do you have a milestone set for this incident? If the answer is no, then the template can advise the user to add a milestone. If the answer is yes, the template can advise the user to assign someone to the commander role: 

                                
{% if incident.current_milestone == "acknowledged" and incident.incident_roles[0].name != 'Incident Commander' %}
 You have started this incident but haven't assigned a commander yet
 Run `/fh assign role` to assign a commander
{% endif %}
                                
                        

Another great way to use Command extensions is to store specific information that your team members might need at any given time. Consider this: your company may require that you use only certain terminology to refer to incidents, since the language around things like status pages can be regulated by SLA agreements. If your SLA says you can't use the word "outage," how do you know what word to use instead? You could create a command called /fh status-messaging, with the reply template providing the exact language your team can use to announce a status update (or otherwise refer to an outage).

Using arguments to return data

Here's another example: imagine that you want to quickly query your Incident dashboards in Datadog. Create a command named /fh dd-dash. Then pull up your Incident dashboard in Datadog and copy the url into the reply template for your command, like this:

undefined

The url likely contains an ID that's linked to the ID for certain microservices you're running in AWS regions. You can replace that ID with an argument variable, like this:

undefined

Then append your command with the argument: instead of /fh dd-dash, run /fh dd-dash aws-east-2. By specifying aws-east-2, you're saying: "hey, give me a link to my Datadog dashboard in the AWS East 2 region" (as long as they use the same style of naming convention).


Think of Command extensions as a tool for customizing Slack to instantly provide any information you need. Check out our built-in Slack commands first; then take a look at the operations available in Liquid and get creative with your custom commands!

See FireHydrant in action

See how service catalog, incident management, and incident communications come together in a live demo.

Get a demo