Skip to content

Sample Slack app that uses a Bot to create per-channel webhooks

License

Notifications You must be signed in to change notification settings

slackapi/template-channel-webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Per-channel webhook template

A bot that creates an incoming webhook URL for every channel it joins. Using the webhook URL, any user can set up integrations to post notifications into that channel.

channel-webhook-template

Setup

Create a Slack app

  1. Create an app at api.slack.com/apps
  2. Click on Bot Users
  3. Add a bot user (choose a username and enable 'Always Show My Bot as Online')
  4. Click on Install App in the sidebar
  5. Install the app and copy the xoxb- token

Run locally or Remix on Glitch

  1. Get the code
  2. Set the following environment variables to .env (see .env.sample):
    • SLACK_TOKEN: Your app's xoxb- token value (available on the Install App page)
    • SLACK_VERIFICATION_TOKEN: Your app's verification token (available on the Basic Information page)
    • PORT: The port that you're running ngrok on
    • BASE_URL: Your ngrok URL
  3. If you're running the app locally:
    1. Start the app (npm start)
    2. In another windown, start ngrok on the same port as your webserver (ngrok http $PORT)

Enable the Events API

  1. Go back to the app settings and click on Events Subscriptions.
  2. Set the Request URL to your ngrok or Glitch URL + /events
  3. On the same page, subscribe to the member_joined_channel bot event

In Slack

  1. Invite the bot into a channel. You should see a message posted with the webhook URL

About

Sample Slack app that uses a Bot to create per-channel webhooks

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published