Build a Slack bot using Postman Flows

This tutorial shows you how to create a Slack bot in Postman Flows. The bot will enable you to use Slack commands to get stock quotes.


Connect a Flow to a Slack app

Create a new app in Slack here, give it a name, and then create a slash command which will enable you to interact with it. When making the slash command, for the request URL use which is an already deployed Flow which can be found here.

Create Slack app

Next, enable webhooks so you can send messages to the Slack app from Postman Flows. You'll need to reinstall the app after you do this, as shown in the GIF. Select a channel from Slack that you'll want to interact with it in from the dropdown list.

Enable Slack webhooks

For the final step, run the command you created in the first step in the Slack channel you installed it to and view your recipe!

Enable Slack webhooks

Building your own Slack app with Postman Flows


  1. Sign up for a free Slack account.
  2. Sign up for a free account and get your API key.

To make your own Slack app from scratch with Postman Flows, follow the same steps as Connect a Flow to a Slack app. This time, name the app Stock App, make the stock-quote command, and use the URL of the new Flow you're going to make.

New Slack command

Next, fork (which means copy in this case) the collection found here and the environment found here. These contain the saved requests and variables you're going to use in this Flow.

In the environment you forked, paste your API key where it says YOUR_API_KEY_HERE. You're ready to start building the Flow.

To start the Flow, create two Evaluate blocks, then paste the following functions:

  • $match(slack_text,'(?<=text=)[^&]+')[0]
  • $replace($match(slack_text,'(?<=commands%2F)[^&]+')[0],"%2F","/")

The first function gets the text after the stock-quote slash command from the webhook Slack sends. The second function gets the destination in Slack your Flow will send the reply to.

Create Evaluate blocks

Next, copy the text after the stock-quote command that you have in the Evaluate block (which is the stock ticker). Call the API to get the quote.

Create a Send Request block and select Get stock quote from the collection that you forked. Select the Slack Stock Bot environment you also forked and connect the Evaluate block to the ticker variable. This is how information like the ticker is passed from the Evaluate block into the Send Request block.

Create Send Request block

The final step is to send all this information back to the Slack app.

Because Slack requires the sent text to be in JSON format, create a Record block, name the key text, and add a Select block. You can either use the dropdown list to select or enter body.results.0.c, which is how stores their stock quotes.

Next, create a new Send Request block. Drag the output of the Record block to the message_to_slack variable. Drag a connection from the second Evaluate block (which holds the destination in Slack to reply to) to the slack_hook_url input of the Send Request block.

Send to Slack

All that's left is to select the Deploy button and try it out in Slack!

See the result

Last modified: 2024/06/05