This example shows a fully functioning but very simple application using the Slack Event Adapter.
- Create an app at api.slack.com/apps
- Click on
Bot Users
on the left side navigation - Give your bot user a name (e.g. "@greetandreact"), turn Always Show My Bot as Online on, and save your changes
- Get the code
- Either clone this repo and run
npm install
- Or visit glitch.com/edit/#!/remix/slack-greet-and-react-example
- Either clone this repo and run
- Set the following environment variables (all available on the Basic Information page) to
.env
(see.env.sample
if you're developing locally)SLACK_CLIENT_ID
: You app's Client IDSLACK_CLIENT_SECRET
: Your app's Client SecretSLACK_VERIFICATION_TOKEN
: Your app's Verification Token
- If you're running the app locally:
- Start the app (
node index.js
) - In another window, start ngrok on the same port as your webserver (
ngrok http $PORT
)
- Start the app (
- Go back to the app settings and click on
Event Subscriptions
on the left side navigation - Enable events and enter your Request URL:
- ngrok or Glitch URL +
/slack/events
- ngrok or Glitch URL +
- After you set up the Request URL, you should add event subscriptions under the "Bot Events" category. Add
message.channels
andreaction_added
. - Go to
OAuth & Permissions
item on the left side navigation, and input the Redirect URL:- ngrok or Glitch URL +
/auth/slack/callback
- ngrok or Glitch URL +
- Visit the URL of your development proxy
- ngrok or Glitch URL
- Click the "Add to Slack" button, and complete the installation
- You can invite the Bot User into a channel (e.g.
/invite @greetandreact
), and say "hi" in the channel. It should respond to you. You can also add reactions to messages and the Bot User will send a message using the same emoji.