Slack Command Extensions

Command extensions allow your team to add custom functionality to the FireHydrant Slack bot. This section provides information on how to use these extensions once they've been set up.

To execute a command extension, you need to enter it into the Slack message box in the following format:

/fh <command-name> <arg1> <arg2> ...
  • /fh is the prefix that invokes the FireHydrant bot.
  • <command-name> is the name of the command extension that you want to execute. This is defined when you set up the command extension.
  • <arg1> <arg2> ... are any arguments that your command extension requires.

For instance, if you have a command extension named restart-deployment, you could use it to restart an nginx deployment in a default namespace using the following command:

/fh restart-deployment default nginx-deployment

This would request your internal application to restart the nginx deployment in the specified namespace. The command's response will depend on how you've configured the command extension and the status of the requested operation.

Remember that each command extension may require different arguments, so make sure to provide the correct arguments for each command extension you use.

Set Up

FireHydrant command extensions rely on webhooks, you'll need to create a new webhook that is configured for your Slack extension. Follow the guide here, to create a new webhook.

Creating a command extension

Fields to configure and examples.

Field Examples
Command Name example-command
Help Description "This command allows you to perform action X."
Command Type Reply, Webhook
Reply Template {{ args[0] }}

Usage

Once you've configured a Slack command extension, you can run the command in Slack by typing:

/fh command-name arg1 arg2
Using a command extension

Webhook Payloads

When using a webhook operation in command extensions, you'll receive a payload that looks like this:

{
"data": {
"callback": {
"expiration": "2023-07-24T23:29:34Z",
"url": "https://app.firehydrant.io/integrations/slack/webhooks/eyJhbGNiJ9.eyJpc3MiOeHRlb4LWRiYjYtNDg0Yi1hMWVmLTRlYzgwNzVmZDBjOCIsImV4cCI6MTY5MDI0MTM3NH0.GVXKsHeYhVTg7kzT5Xnba46L-GWhE"
},
"command_arguments": [
"default",
"nginx-deployment"
],
"command_extension": {
"description": "Description",
"id": "7d5fc662-572c-45c4-bbd1-17e23830fe39",
"name": "restart-deployment"
},
"firehydrant_user": {
"email": "bobby+dalmatians@firehydrant.io",
"id": "2af3339f-9d81-434b-a208-427d6d85c124",
"name": "Robert Ross",
"source": "firehydrant_user"
},
"payload": {},
"payload_type": "json"
},
"event": {
"operation": "CREATED",
"resource_type": "command_extension"
}
}

Responding to Webhook Callbacks

The callback URL is a unique URL that you can use to reply with incident notes on your timeline. This is useful to reply with asynchronous tasks that your operation is running.

For example, you can add notes back to your incident with:

POST /integrations/slack/webhooks/eyJhbGNiJ9.eyJpc3MiOeHRlb4LWRiYjYtNDg0Yi1hMWVmLTRlYzgwNzVmZDBjOCIsImV4cCI6MTY5MDI0MTM3NH0.GVXKsHeYhVTg7kzT5Xnba46L-GWhE HTTP/1.1
Host: app.firehydrant.io
Content-Type: application/json
Content-Length: 120

{
"reply_type": "actions",
"actions": [
{
"action": "new_note",
"body": "Deployment has successfully restarted"
}
]
}

Last updated on 2/9/2024