There are two way of connecting to Slack: with WebSockets or with web hooks. The first one is recommended since it doesn’t require any use of reverse proxies like ngrok.

With WebSocket

  1. Go to your Slack apps dashboard and click on Create New App
  2. 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

  1. Get the Signing Secret in section Basic Information under App Credentials
  2. 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
  3. Check the Socket Mode
  4. 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’

With Web Hooks

  1. 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

Ngrok

Ngrok

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.