Slack Slash Integration

Building a custom Slack slash command is a great way to integrate a back office system and make your team more productive. Slack is an indispensable tool for business communication and collaboration. One of its most powerful aspects is its ability to integrate with your business processes via its APIs. Slack is extensible in a virtually unlimited number of ways and can act as the central interface for many of your company’s resources and systems.

Slash commands are a simple way of triggering a process via Slack’s chat interface. For example, one of the default slash commands available in Slack allows you to conveniently change your active status without leaving the chat interface. Another use of a slash command is to launch a meeting with a list of colleagues, or search for a resource in an internal system, perhaps an internal FAQ or customer contact database.

When you run a slash command, Slack makes a web request to a custom endpoint of your choosing and passes along data to the receiving application’s business logic.

The Typical Way to Create a Slash Command

Creating a slash command requires that you write some backend code to handle the incoming HTTP request that Slack sends when you run the command. You also need to host and manage the app, and provision SSL certificates. It’s also a good idea to implement logic that verifies the authenticity of inbound requests to make sure they’re genuine and coming from Slack and not from an unauthorized 3rd party. Slack signs all of its outbound calls with a standard HMAC-SHA256 keyed hash for this purpose. A common way of hosting a Slack app backend is to use a cloud platform like AWS Lambda or Google Cloud. This requires development knowledge however.

The Faster Way to Create a Slash Command

Another solution is to use a lowcode platform like Pipegears to create the business logic visually by dragging modules and connecting them. PipeGears hosts applications and automatically provide HTTPS endpoints ready to receive inbound requests from Slack. They also handle the HMAC hash verification process automatically which saves you time.

Our Slack Integration Use Case

One of the most common challenges in a business environment is to make the hoards of data hiding away in disparate systems readily available to the people who need it. An example of this is a contact database living in an internally managed SQL database. PipeGears can meet this challenge and do it quickly. We’ve created an implementation of a backend for a slash command that demonstrates the use case.

The goal is to add a custom slash command named /lookup to our Slack environment that accepts a first or last name, or even a partial name segment, finds a match in a database, then displays the full contact in Slack.

Slash Command Example

For this demo, we created this sample dataset of contacts in a MySQL database:

Sample Data

The expected result of a command /lookup mary with the sample dataset provided looks something like this:

Slack Slash Command Result

Adding the Slash Command to Slack

First you need to create a Slack App in your Slack account at After creating the app, add a slash command from the features and functionality options in your app settings.

Create a Slack App

Slack lets you configure the URL that receives requests when someone runs a command. In this example, the slash command is set to send its data to which is a URL created in the PipeGears application that will handle inbound calls from Slack. Here is the slash command as configured in Slack:

Slack Slash Command Configuration

The last step in configuring the slash command is to install the app in your Slack environment and authorize it. At this point, the slash command is active in your Slack console and issues HTTPS requests to the URL you defined in the step above. You’ll need to copy the signing secret from your app settings in Slack and add it to the Slack Webhook in your PipeGears flow.

Slack Signing Secret

Building the Backend

The backend to power this command is a simple flow that’s triggered when Slack sends a request to the slash command’s URL. PipeGears provides a convenient Slack trigger component that creates a secured endpoint to receive HTTPS calls from Slack. The implementation of a basic working solution takes about ten minutes and the end result looks like this:

PipeGears For for Slack Slash Command Backend
PipeGears Flow to handle Slack Slash Command

The flow begins with the Slack Webhook, does a simple string extraction to extract the term “mary”, issues an SQL query to find a match, then follows a set of conditional paths based on one of three possible outcomes:

  1. There was a match, in which case the flow ends by returning contact information to Slack,
  2. There was no match, so the flow ends by returning an appropriate message, like “nothing found”, or
  3. The database didn’t respond (for whatever reason) in which case the flow ends by returning an error message.

In this example, an SQL DataSource is configured as a global resource available to any SQL query node within the flow.

Watch the Full Integration Demo

And that’s it! A working implementation that’s hosted, secured with a valid SSL certificate and automatically handles the HMAC signing process to authenticate requests and ensure that they are really from Slack. It’s somewhat basic, but a good start for a more feature rich implementation. Watch the demo video to see the entire process and get a more in-depth explanation. Then create an account on PipeGears and try it yourself!

Slack Slash Integration Demo