Slack Message Router
@dylburger
code:
data:privatelast updated:4 years ago
@dylburger/
Slack Message Router

Overview

This workflow listens for messages containing "Star Wars", and sends a message in response:

You can modify this workflow to listen for any message pattern, in any channel, and run any Node.js code or actions in any integrated apps.

Prerequisites / Permissions

  1. First, create a new Slack app.
  2. In the app's OAuth & Permissions section, copy its Bot User OAuth Access Token.
  3. Copy this workflow (button in the top-right). Pipedream will generate an endpoint URL unique to this workflow where you'll send new messages in your desired Slack channel.
  4. In the workflow, press the Connect Account button at the top of the parse_filter_and_send_response step, and enter the Slack bot token from Step 2 above.
  5. In the Event Subscriptions section, toggle Enable Events on, and enter the endpoint URL from the workflow. Pipedream automatically responds to the url_verification event Slack sends to this endpoint. You'll see this HTTP request in the Inspector.
  6. In the Subscribe to bot events section, select message.channels. This lets the Slack bot will listen for messages sent to any channel it's added to.
  7. The bot needs permission to post to channels and get basic channel info. Add the channels:read and chat:write permissions. The channels:history permission should have been automatically added when you requested to listen for new messages in channels, above.
  1. You should be prompted to install the app to your workspace. You can then add the bot to new channels, as described below, and you'll get new messages

Usage

This workflow requires you add the bot manually to each channel where you'd like to listen for messages. Just click on the channel's member list, expand the Apps section, and add the app:

Then send a message with "Star Wars" in the text, and you'll get the forceful response.

You can, optionally, create a workflow that listens for channel_created messages and uses the Slack API to join that channel (see this SO post).