https://github.com/slack-samples/javascript-channel-webhooks
Sample Slack app that uses a Bot to create per-channel webhooks
https://github.com/slack-samples/javascript-channel-webhooks
slack-blueprint
Last synced: 6 months ago
JSON representation
Sample Slack app that uses a Bot to create per-channel webhooks
- Host: GitHub
- URL: https://github.com/slack-samples/javascript-channel-webhooks
- Owner: slackapi
- License: mit
- Created: 2017-06-12T17:58:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-05T11:08:49.000Z (almost 6 years ago)
- Last Synced: 2024-10-04T21:35:46.437Z (over 1 year ago)
- Topics: slack-blueprint
- Language: JavaScript
- Size: 8.79 KB
- Stars: 31
- Watchers: 7
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 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.

## Setup
#### Create a Slack app
1. Create an app at api.slack.com/apps
1. Click on `Bot Users`
1. Add a bot user (choose a username and enable 'Always Show My Bot as Online')
1. Click on `Install App` in the sidebar
1. Install the app and copy the `xoxb-` token
#### Run locally or [](https://glitch.com/edit/#!/remix/slack-channel-webhook-blueprint)
1. Get the code
* Either clone this repo and run `npm install`
* Or visit https://glitch.com/edit/#!/remix/slack-channel-webhook-blueprint
1. 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
1. If you're running the app locally:
1. Start the app (`npm start`)
1. 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.
1. Set the Request URL to your ngrok or Glitch URL + /events
1. On the same page, subscribe to the `member_joined_channel` [**bot** event](https://cloud.githubusercontent.com/assets/700173/26603331/4f188f90-453b-11e7-9b6d-9ca541f0cbf1.png)
#### In Slack
1. Invite the bot into a channel. You should see a message posted with the webhook URL