-
-
Notifications
You must be signed in to change notification settings - Fork 188
Slack Receiver node
There are two way of connecting to Slack: with WebSockets or with web hooks. The first one is reccomended since it doesn't require any use of reverse proxies like ngrok
- Go to your Slack apps dashboard and click on Create New App
- Select From app manifest and paste this code
display_information:
name: MySlackApp
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: MySlackApp
always_online: true
oauth_config:
scopes:
bot:
- channels:history
- channels:join
- chat:write
- chat:write.customize
- commands
- im:history
- users:write
- files:read
- files:write
settings:
event_subscriptions:
bot_events:
- message.channels
- message.im
interactivity:
is_enabled: true
org_deploy_enabled: false
socket_mode_enabled: true
token_rotation_enabled: false
then select the Workspace to install the app to, go through all steps and finally click on Create
- Get the Signing Secret in section Basic Information under App Credentials
- Get the Bot Token in section Oauth & Permissions under OAuth Tokens for Your Workspace: click in Install To Workspace and get the generated Bot User OAuth Token
- Check the Socket Mode
- Get the App-Level Token in Basic Information under App-Level Tokens: click on Generate Token and Scopes, pick any name for the token, add the scope connections:write then click on 'Generate'
- Slack API talks to Red-Bot via a https callback (a self signed certificate is not enough). We'll use ngrok to create a https tunnel for our local Node-RED instance. Install it, then open a shell window and run
ngrok http 3001
You should get something like
Grab the https address you get, something like https://123123.ngrok.io, this is the base url that points back to your Node-RED instance.
Warning Slack API libraries are not compatible with the stack of middlewares used by Node-RED, for this reason the Slack webhooks in RedBot run in a separate Express server on a different port (the default one in 3001). Keep in mind that in production it's needed to open the firewall in order to expose this port.
- Go to your Slack apps dashboard and click on Create New App
- Select From app manifest and paste this code
display_information:
name: MySlack WebHook
features:
app_home:
home_tab_enabled: false
messages_tab_enabled: true
messages_tab_read_only_enabled: false
bot_user:
display_name: MySlack WebHook
always_online: true
oauth_config:
scopes:
bot:
- channels:history
- channels:join
- chat:write
- commands
- files:read
- files:write
- im:history
- users:write
- chat:write.customize
settings:
event_subscriptions:
request_url: https://123456.ngrok.io/slack/events
bot_events:
- message.channels
- message.im
interactivity:
is_enabled: true
request_url: https://123456.ngrok.io/slack/events
org_deploy_enabled: false
socket_mode_enabled: false
token_rotation_enabled: false
Replace the 123456.ngrok.io domain with the one got in step 1
- Get the Signing Secret in section Basic Information under App Credentials
- Get the Bot Token in section Oauth & Permissions under OAuth Tokens for Your Workspace: click in Install To Workspace and get the generated Bot User OAuth Token
- Un-check Use WebSocket
- In order to support Slack Commands, use as Request URL the same callback (i.e. https://123456.ngrok.io/slack/events, be sure to replace the url got in step 1)
Slack Receiver
and Slack Sender
have a double bot configuration for development and production. By default is used the development configuration. To use production configuration, edit Node-RED settings file (settings.js) and set the environment global variable to "production". See here for more details.
RedBot also supports Slack events, in the chatbot use the Rules node to control the flow based on incoming events (the payload of the event will be in msg.payload
) and use the Support table node to see the list of supported events.