ListenSlack allows for receiving real-time messages and commands from Slack using Slack's Events API. This Processor does not provide any capabilities for retrieving historical messages. However, the ConsumeSlack Processor provides the ability to do so. This Processor is generally used when implementing a bot in NiFi, or when it is okay to lose messages in the case that NiFi or this Processor is stopped for more than 5 minutes.

This Processor may be used to listen for either Message Events, or Slack Commands. For example, you may wish to create a Slack App that receives the /nifi command and when received, performs some task. The Processor does not allow listening for both Message Events and Commands, as the output format is very different for the two, and this would lead to significant confusion. Instead, if there is a desire to consume both Message Events and Commands, two ListenSlack Processors should be used - one for Messages and another the Commands.

Note that unlike the ConsumeSlack Processor, ListenSlack does not require that a Channel name or ID be provided. This is because the Processor listens for Events/Commands from all channels (and "channel-like" conversations) that the application has been added to.

Slack Setup

In order use this Processor, it requires that a Slack App be created and installed in your Slack workspace. Additionally, the App must have Socket Mode enabled. Please see Slack's documentation for the latest information on how to create an Application and install it into your workspace.

At the time of this writing, the following steps may be used to create a Slack App with the necessary scopes. However, these instructions are subject to change at any time, so it is best to read through Slack's Quickstart Guide.

Configuring the Tokens

Now that your Slack Application has been created and configured, you will need to provide the ListenSlack Processor with two tokens: the App Token and the Bot token. To get the App Token, go to your Slack Application's configuration page. On the left-hand side, navigate to "Basic Information." Scroll down to "App-Level Tokens" and click on the token that you created in the Slack Setup section above. This will provide you with a pop-up showing your App Token. Click the "Copy" button and paste the value into your Processor's configuration. Then click "Done" to close the popup.

To obtain your Bot Token, again in the Slack Application's configuration page, navigate to the "OAuth & Permissions" section on the left-hand side. Under the "OAuth Tokens for Your Workspace" section, click the "Copy" button under the "Bot User OAuth Token" and paste this into your NiFi Processor's configuration.